fix(core): update

This commit is contained in:
Philipp Kunz 2019-05-27 15:16:38 +02:00
parent eb137c3871
commit c21c10d7f2

View File

@ -43,20 +43,25 @@ export class SmartExit {
constructor() { constructor() {
// do app specific cleaning before exiting // do app specific cleaning before exiting
process.on('exit', async () => { process.on('exit', async (code) => {
if (code === 0) {
console.log('SMARTEXIT: Process wants to exit');
await this.killAll(); await this.killAll();
}
}); });
// catch ctrl+c event and exit normally // catch ctrl+c event and exit normally
process.on('SIGINT', async () => { process.on('SIGINT', async () => {
console.log('Ctrl-C...'); console.log('SMARTEXIT: Ctrl-C... or SIGINT signal received!');
await this.killAll(); await this.killAll();
}); });
//catch uncaught exceptions, trace, then exit normally //catch uncaught exceptions, trace, then exit normally
process.on('uncaughtException', async err => { process.on('uncaughtException', async err => {
console.log('Ctrl-C...'); console.log('SMARTEXIT: uncaught exception...');
console.log(err);
await this.killAll(); await this.killAll();
process.exit(1);
}); });
} }
} }