summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Wu2017-01-20 09:39:04 +0800
committerGitHub2017-01-20 09:39:04 +0800
commit1de4242473b74afdb2d3e358e3b213ef156ca0de (patch)
treefaa9e0a4f870445461f6aed6705825d9af4075d4
parent14734372956fa5d6c6159ba8c4b00a90b80ea8d6 (diff)
parent20dc3127b106e18b41573299f75d75c6b77f958d (diff)
Merge pull request #321 from DrMurx/gracefulSigtermHandling
Handle SIGTERM the same way SIGINT is handled
-rw-r--r--app.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/app.js b/app.js
index 7b5e6197..ba0b67d3 100644
--- a/app.js
+++ b/app.js
@@ -626,8 +626,8 @@ process.on('uncaughtException', function (err) {
process.exit(1);
});
-// gracefully exit
-process.on('SIGINT', function () {
+// install exit handler
+function handleTermSignals() {
config.maintenance = true;
// disconnect all socket.io clients
Object.keys(io.sockets.sockets).forEach(function (key) {
@@ -649,4 +649,6 @@ process.on('SIGINT', function () {
});
}
}, 100);
-});
+}
+process.on('SIGINT', handleTermSignals);
+process.on('SIGTERM', handleTermSignals);