Skip to content

Commit

Permalink
chore: trap SIGINT, SIGTERM and SIGHUP for auto-closing
Browse files Browse the repository at this point in the history
  • Loading branch information
Mastercuber committed Aug 16, 2023
1 parent b40e7f4 commit d02cce4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/listen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,11 @@ export async function listen(
}

if (listhenOptions.autoClose) {
process.setMaxListeners(4);
process.on("exit", () => close());
process.on("SIGINT", () => process.exit(0)); // Ctrl + C
process.on("SIGTERM", () => process.exit(0)); // Terminate
process.on("SIGHUP", () => process.exit(0)); // Closed terminal
}

return <Listener>{
Expand Down

0 comments on commit d02cce4

Please sign in to comment.