节点 oracledb 连接池在节点进程终止之前未关闭
Node oracledb connection pool not closing before node process termination
终止时节点应用程序未关闭数据库会话。我目前正在使用 node-cleanup 库,但是当池连接数超过一定数量时,pool.close()
函数将需要一些时间来解析,因此节点在不关闭池的情况下终止并且会话在 db.Have 已经在 oracle DB 中设置了适当的超时,以便拦截和清理不活动的会话。但是想知道有什么方法可以阻止节点进程退出,以便 pool.close()
得到解决。
nodeCleanup(function(exitCode, signal) {
console.log('Node server exiting with signal : ' + signal);
console.log('Node server exiting with exitCode : ' + exitCode);
db.getPool().close();
});
但是如果我使用以下服务然后退出节点,所有数据库会话都会正确关闭。
app.get('/closePool', function(req, res, next) {
db.getPool().close(function(err) {
if (err)
next(err);
res.send('Pool closed');
});
})
您是否尝试过使用 beforeExit
事件? https://nodejs.org/api/process.html#process_event_beforeexit
终止时节点应用程序未关闭数据库会话。我目前正在使用 node-cleanup 库,但是当池连接数超过一定数量时,pool.close()
函数将需要一些时间来解析,因此节点在不关闭池的情况下终止并且会话在 db.Have 已经在 oracle DB 中设置了适当的超时,以便拦截和清理不活动的会话。但是想知道有什么方法可以阻止节点进程退出,以便 pool.close()
得到解决。
nodeCleanup(function(exitCode, signal) {
console.log('Node server exiting with signal : ' + signal);
console.log('Node server exiting with exitCode : ' + exitCode);
db.getPool().close();
});
但是如果我使用以下服务然后退出节点,所有数据库会话都会正确关闭。
app.get('/closePool', function(req, res, next) {
db.getPool().close(function(err) {
if (err)
next(err);
res.send('Pool closed');
});
})
您是否尝试过使用 beforeExit
事件? https://nodejs.org/api/process.html#process_event_beforeexit