diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f411b4e..245173d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Updated ### Fixed +- Handle SIGTERM messages ## [2.7.1] - 2019-04-02 diff --git a/js/app.js b/js/app.js index 95c9693b..4a10ba6d 100644 --- a/js/app.js +++ b/js/app.js @@ -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();