From d02cce4f1ba03282d80f6c6d71e09ff41a997d68 Mon Sep 17 00:00:00 2001 From: Armin Kunkel Date: Wed, 16 Aug 2023 22:51:01 +0200 Subject: [PATCH] chore: trap SIGINT, SIGTERM and SIGHUP for auto-closing --- src/listen.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/listen.ts b/src/listen.ts index c678d3c..957264f 100644 --- a/src/listen.ts +++ b/src/listen.ts @@ -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 {