Skip to content

Commit

Permalink
feat: ignore first sigint
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Mar 22, 2023
1 parent afdd3e9 commit b3d7368
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"liqe": "^3.6.0",
"pretty-ms": "^7.0.0",
"prettyjson": "^1.2.5",
"roarr": "^7.14.3",
"roarr": "^7.15.0",
"socket.io-client": "^4.6.1",
"split2": "^4.1.0",
"yargs": "^17.7.1"
Expand Down
20 changes: 16 additions & 4 deletions src/bin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,21 @@ stream = stream.pipe(

stream.pipe(process.stdout);

let firstSigint = true;

process.on('SIGINT', () => {
setTimeout(() => {
// eslint-disable-next-line node/no-process-exit
process.exit();
}, 250);
if (firstSigint) {
firstSigint = false;

console.log(
'[@roarr/cli] received SIGINT; waiting for the stream to close',
);

return;
}

console.log('[@roarr/cli] received second SIGINT; force exiting');

// eslint-disable-next-line node/no-process-exit
process.exit(1);
});

0 comments on commit b3d7368

Please sign in to comment.