|
|
|
@ -95,8 +95,9 @@ function printStartupInfo() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function addProcessHandlers() {
|
|
|
|
|
process.on('SIGTERM', shutdown);
|
|
|
|
|
process.on('SIGINT', shutdown);
|
|
|
|
|
['SIGTERM', 'SIGINT', 'SIGQUIT'].forEach((signal) => {
|
|
|
|
|
process.on(signal, () => shutdown());
|
|
|
|
|
});
|
|
|
|
|
process.on('SIGHUP', restart);
|
|
|
|
|
process.on('uncaughtException', (err) => {
|
|
|
|
|
winston.error(err.stack);
|
|
|
|
@ -130,7 +131,7 @@ function restart() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function shutdown(code) {
|
|
|
|
|
winston.info('[app] Shutdown (SIGTERM/SIGINT) Initialised.');
|
|
|
|
|
winston.info('[app] Shutdown (SIGTERM/SIGINT/SIGQUIT) Initialised.');
|
|
|
|
|
try {
|
|
|
|
|
await require('./webserver').destroy();
|
|
|
|
|
winston.info('[app] Web server closed to connections.');
|
|
|
|
@ -142,6 +143,7 @@ async function shutdown(code) {
|
|
|
|
|
process.exit(code || 0);
|
|
|
|
|
} catch (err) {
|
|
|
|
|
winston.error(err.stack);
|
|
|
|
|
|
|
|
|
|
return process.exit(code || 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|