update: app.js: enable graceful shutdown with SIGTERM

This commit is contained in:
zefie
2021-08-05 17:50:56 -04:00
parent 5d48c58c1d
commit 60dc9bcc4c

View File

@@ -14,6 +14,20 @@ var WTVSec = require('./WTVSec.js');
var WTVClientCapabilities = require('./WTVClientCapabilities.js'); var WTVClientCapabilities = require('./WTVClientCapabilities.js');
var WTVClientSessionData = require('./WTVClientSessionData.js'); var WTVClientSessionData = require('./WTVClientSessionData.js');
process
.on('SIGTERM', shutdown('SIGTERM'))
.on('SIGINT', shutdown('SIGINT'))
.on('uncaughtException', shutdown('uncaughtException'));
function shutdown(signal) {
return (err) => {
console.log("Received signal", signal);
if (err) console.error(err.stack || err);
process.exit(err ? 1 : 0);
};
}
// Where we store our session information // Where we store our session information
var ssid_sessions = new Array(); var ssid_sessions = new Array();
var socket_sessions = new Array(); var socket_sessions = new Array();