Gracefully shut down the server on signals (#2246)

This commit is contained in:
Dan Abramov
2017-05-19 14:59:28 +01:00
committed by GitHub
parent 4a32171331
commit e0b444e517

View File

@@ -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) {