Handle SIGTERM

This commit is contained in:
Benoit Schweblin 2018-03-30 13:04:41 +01:00
parent 83a47007b0
commit bde9cf0596

View File

@ -18,3 +18,10 @@ const httpServer = http.createServer(app);
httpServer.listen(port, null, () => { httpServer.listen(port, null, () => {
console.log(`HTTP server started: http://localhost:${port}`); console.log(`HTTP server started: http://localhost:${port}`);
}); });
// Handle graceful shutdown
process.on('SIGTERM', () => {
httpServer.close(() => {
process.exit(0);
});
});