Gracefully shutdown on both SIGINT + SIGTERM
Most service managers (systemd, docker, etc) use SIGTERM as the shutdown signal by default rather than SIGINT (which is used for interactive CTRL-C).
This commit is contained in:
parent
97cec114f6
commit
cf5c818ee3
1 changed files with 5 additions and 2 deletions
|
|
@ -99,8 +99,11 @@ const server = app.listen(port, () => {
|
|||
});
|
||||
|
||||
// graceful shutdown
|
||||
process.on('SIGINT', () => {
|
||||
const gracefulShutdown = () => {
|
||||
server.close(() => {
|
||||
console.log('Server closed');
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
process.on('SIGINT', gracefulShutdown);
|
||||
process.on('SIGTERM', gracefulShutdown);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue