Skip to content

Commit

Permalink
Explicitely but gracefully handle SIGINT and SIGTERM signals. (#787)
Browse files Browse the repository at this point in the history
Fixes #557.
  • Loading branch information
lucsky authored and SpaceK33z committed Mar 9, 2017
1 parent 85de417 commit 42cd23c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bin/webpack-dev-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,14 @@ function startDevServer(wpOpt, options) {
throw e;
}

["SIGINT", "SIGTERM"].forEach(function(sig) {
process.on(sig, function() {
console.log(`Gracefully shutting down server after ${sig}...`);
server.close();
process.exit(); // eslint-disable-line no-process-exit
});
});

if(options.socket) {
server.listeningApp.on("error", function(e) {
if(e.code === "EADDRINUSE") {
Expand Down

0 comments on commit 42cd23c

Please sign in to comment.