Catch SIGTERM for graceful shutdown (#3266)

Shut down database connection and exit the node process
when SIGTERM is encountered. This is especially important
when nodejs is run as PID1, e.g. in a docker container.

Shutting down connections to clients (browsers) is beyond
this patche's scope.

Resolves #3265
This commit is contained in:
Rainer Rillke 2017-11-04 22:59:19 +01:00 committed by Luiza Pagliari
parent 32027134cb
commit f12debd5c7
1 changed files with 3 additions and 0 deletions

View File

@ -49,5 +49,8 @@ exports.expressCreateServer = function (hook_name, args, cb) {
//sigint is so far not working on windows
//https://github.com/joyent/node/issues/1553
process.on('SIGINT', exports.gracefulShutdown);
// when running as PID1 (e.g. in docker container)
// allow graceful shutdown on SIGTERM c.f. #3265
process.on('SIGTERM', exports.gracefulShutdown);
}
}