update: app.js: enable graceful shutdown with SIGTERM
This commit is contained in:
@@ -14,6 +14,20 @@ var WTVSec = require('./WTVSec.js');
|
||||
var WTVClientCapabilities = require('./WTVClientCapabilities.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
|
||||
var ssid_sessions = new Array();
|
||||
var socket_sessions = new Array();
|
||||
@@ -1330,4 +1344,4 @@ initstring = initstring.substring(0, initstring.length - 2);
|
||||
|
||||
console.log(" * Started server on ports " + initstring + "...")
|
||||
var listening_ip_string = (minisrv_config.config.bind_ip != "0.0.0.0") ? "IP: " + minisrv_config.config.bind_ip : "all interfaces";
|
||||
console.log(" * Listening on", listening_ip_string,"~","Service IP:", service_ip);
|
||||
console.log(" * Listening on", listening_ip_string,"~","Service IP:", service_ip);
|
||||
Reference in New Issue
Block a user