Handle SIGTERM messages

This commit is contained in:
Michaël Arnauts 2019-04-06 20:50:54 +02:00 committed by GitHub
parent 8b0b70e757
commit fd53541719
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -263,6 +263,15 @@ var App = function() {
this.stop();
process.exit(0);
});
/* We also need to listen to SIGTERM signals so we stop everything when we are asked to stop by the OS.
*/
process.on("SIGTERM", () => {
console.log("[SIGTERM] Received. Shutting down server...");
setTimeout(() => { process.exit(0); }, 3000); // Force quit after 3 seconds
this.stop();
process.exit(0);
});
};
module.exports = new App();