在使用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