在使用pg-promise
构建主/副本postgres连接的情况下,是否有办法在发生副本中断时重建这些连接?
而不是在与initOptions传递的错误函数中做process.exitCode = 1;
,并重建服务启动时只有工作连接...有没有更好的方法来删除失败的连接(甚至更好,如果它的副本和process.exitCode如果它的主要)?在Nodejs中重建连接,pg-promise
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()'但随后的应用程序需要知道停止接受的连接同时 – Cmag