correctly close idle connections #920

This commit is contained in:
SPRINX0\prochazka
2024-10-14 14:03:07 +02:00
parent 06753ff312
commit f80ae284fa
5 changed files with 38 additions and 25 deletions

View File

@@ -329,8 +329,9 @@ async function handleSqlPreview({ msgid, objects, options }) {
await generator.dump();
process.send({ msgtype: 'response', msgid, sql: dmp.s, isTruncated: generator.isTruncated });
if (generator.isUnhandledException) {
setTimeout(() => {
setTimeout(async () => {
logger.error('Exiting because of unhandled exception');
await driver.close(dbhan);
process.exit(0);
}, 500);
}
@@ -406,10 +407,12 @@ async function handleMessage({ msgtype, ...other }) {
function start() {
childProcessChecker();
setInterval(() => {
setInterval(async () => {
const time = new Date().getTime();
if (time - lastPing > 40 * 1000) {
logger.info('Database connection not alive, exiting');
const driver = requireEngineDriver(storedConnection);
await driver.close(dbhan);
process.exit(0);
}
}, 10 * 1000);