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

Commit

Permalink
forced kill on 1s timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
natnat-mc committed Jan 20, 2019
1 parent 7b2b906 commit adebe28
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ require('./src/express');
require('./src/auth');

// setup signal handlers to exit
let dying=false;
['int', 'term', 'hup'].forEach(s => {
s='SIG'+s.toUpperCase();
process.on(s, () => {
if(dying) {
return log.warn("Already dying!");
}
dying=true;
log.notice("Exiting due to "+s);
events.emit('die', s);
setTimeout(process.exit, 1000, 0).unref();
});
});

0 comments on commit adebe28

Please sign in to comment.