【发布时间】:2018-02-24 21:19:36
【问题描述】:
在使用pg-promise 构建主/副本 postgres 连接的情况下,有没有办法在副本中断的情况下重建这些连接?
而不是在与 initOptions 一起传递的错误函数中执行process.exitCode = 1; 并仅在服务启动时重建工作连接...有没有更好的方法来删除失败的连接(如果它是副本,则更好,如果它是 process.exitCode主要)?
const initOptions = {
// global event notification;
error: (error, e) => {
if (e.cn) {
//log
}
process.exitCode =1;
}
};
//singleton
const pgp = require('pg-promise')(initOptions);
// then for each database in config, we connect and start the service
【问题讨论】:
-
我可以做
pgp.end()但是应用程序需要知道在此期间停止接受连接
标签: node.js pg-promise