Skip to content

Commit 42cd23c

Browse files
lucskySpaceK33z
authored andcommitted
Explicitely but gracefully handle SIGINT and SIGTERM signals. (#787)
Fixes #557.
1 parent 85de417 commit 42cd23c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

bin/webpack-dev-server.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,14 @@ function startDevServer(wpOpt, options) {
361361
throw e;
362362
}
363363

364+
["SIGINT", "SIGTERM"].forEach(function(sig) {
365+
process.on(sig, function() {
366+
console.log(`Gracefully shutting down server after ${sig}...`);
367+
server.close();
368+
process.exit(); // eslint-disable-line no-process-exit
369+
});
370+
});
371+
364372
if(options.socket) {
365373
server.listeningApp.on("error", function(e) {
366374
if(e.code === "EADDRINUSE") {

0 commit comments

Comments
 (0)