Skip to content

Commit

Permalink
Gracefully shut down the server on signals (facebook#2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored May 19, 2017
1 parent 64b7194 commit 21ea600
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ choosePort(HOST, DEFAULT_PORT)
console.log(chalk.cyan('Starting the development server...\n'));
openBrowser(urls.localUrlForBrowser);
});

['SIGINT', 'SIGTERM'].forEach(function(sig) {
process.on(sig, function() {
console.log(`Gracefully shutting down server after ${sig}...`);
server.close();
process.exit();
});
});
})
.catch(err => {
if (err && err.message) {
Expand Down

0 comments on commit 21ea600

Please sign in to comment.