Added TERM signal handler

This commit is contained in:
Matthew Jensen committed 2021-02-03 10:00:40 +11:00
1 parent e944364fc2
commit 40bd3edb32
1 file changed
+12
+12
View File
@@ -1966,6 +1966,18 @@ async function startServer(args) {
logger.info("Caught interrupt signal, shutting down");
shutdown();
});
let secondSigterm = false;
process.on("SIGTERM", () => {
if (secondSigterm) {
logger.fatal("Caught second termination, terminating immediately");
// eslint-disable-next-line no-process-exit
process.exit(1);
}
secondSigterm = true;
logger.info("Caught termination signal, shutting down");
shutdown();
});
// terminal closed
process.on("SIGHUP", () => {