Merge pull request #321 from DrMurx/gracefulSigtermHandling

Handle SIGTERM the same way SIGINT is handled
This commit is contained in:
Max Wu 2017-01-20 09:39:04 +08:00 committed by GitHub
commit 1de4242473
1 changed files with 5 additions and 3 deletions

8
app.js
View File

@ -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);