Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
fix: handle exit on windows, closing cmd window
Browse files Browse the repository at this point in the history
  • Loading branch information
shellscape committed May 1, 2018
1 parent 2958e8c commit a5df87b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,24 @@ module.exports = (opts) => {

start(options);

for (const sig of ['SIGINT', 'SIGTERM']) {
process.on(sig, () => { // eslint-disable-line no-loop-func
let closing = false;
const exit = (signal) => {
if (!closing) {
closing = true;
close(() => {
log.info(`Process Ended via ${sig}`);
log.info(`Process Ended via ${signal}`);
server.kill();
process.exit(0);
});
});
}
};

for (const signal of ['SIGINT', 'SIGTERM']) {
process.on(signal, exit(signal));
}

process.on('exit', exit);

return Object.freeze({
close,
compiler: options.compiler,
Expand Down

0 comments on commit a5df87b

Please sign in to comment.