Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
7ad7749ba7 | |||
3f0c9e9fe0 | |||
c1a8c638bf | |||
5d6f5ed282 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartexit",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.14",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartexit",
|
||||
"version": "1.0.12",
|
||||
"version": "1.0.14",
|
||||
"private": false,
|
||||
"description": "do things before one exists a process",
|
||||
"main": "dist/index.js",
|
||||
|
11
ts/index.ts
11
ts/index.ts
@ -32,9 +32,9 @@ export class SmartExit {
|
||||
if (childProcessArg.killed) {
|
||||
return;
|
||||
}
|
||||
process.kill(-pid, 'SIGKILL');
|
||||
process.kill(pid, 'SIGKILL');
|
||||
});
|
||||
process.kill(-pid, 'SIGINT');
|
||||
process.kill(pid, 'SIGINT');
|
||||
|
||||
counter++;
|
||||
});
|
||||
@ -49,15 +49,16 @@ export class SmartExit {
|
||||
if (code === 0) {
|
||||
ora.text('Process wants to exit');
|
||||
await this.killAll();
|
||||
ora.finishSuccess('Exited ok!');
|
||||
} else {
|
||||
ora.finishFail('Exited NOT OK!');
|
||||
}
|
||||
ora.finishSuccess('Exited ok!');
|
||||
});
|
||||
|
||||
// catch ctrl+c event and exit normally
|
||||
process.on('SIGINT', async () => {
|
||||
ora.text('Ctrl-C... or SIGINT signal received!');
|
||||
await this.killAll();
|
||||
ora.finishSuccess('Exited ok!');
|
||||
});
|
||||
|
||||
//catch uncaught exceptions, trace, then exit normally
|
||||
@ -65,7 +66,7 @@ export class SmartExit {
|
||||
ora.text('SMARTEXIT: uncaught exception...');
|
||||
console.log(err);
|
||||
await this.killAll();
|
||||
ora.finishSuccess('Exited ok!');
|
||||
process.exit(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user