From f817047a491e2ea90481a06a127a9e63c37ac4be Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Tue, 24 Jun 2025 12:05:40 +0100 Subject: [PATCH 1/2] MCP-10: handle other signals --- src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 8f5738cf..b9d451c2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,7 +31,7 @@ try { const transport = createEJsonTransport(); - process.on("SIGINT", () => { + const shutdown = () => { logger.info(LogId.serverCloseRequested, "server", `Server close requested`); server @@ -45,7 +45,11 @@ try { logger.error(LogId.serverCloseFailure, "server", `Error closing server: ${error.message}`); process.exit(1); }); - }); + }; + + process.on("SIGINT", shutdown); + process.on("SIGTERM", shutdown); + process.on("SIGQUIT", shutdown); await server.connect(transport); } catch (error: unknown) { From e134a22306626dc91e0e6d8475116d15c2430ad1 Mon Sep 17 00:00:00 2001 From: Bianca Lisle Date: Tue, 24 Jun 2025 12:14:13 +0100 Subject: [PATCH 2/2] address comment --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index b9d451c2..02f9ca36 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,9 +47,9 @@ try { }); }; - process.on("SIGINT", shutdown); - process.on("SIGTERM", shutdown); - process.on("SIGQUIT", shutdown); + process.once("SIGINT", shutdown); + process.once("SIGTERM", shutdown); + process.once("SIGQUIT", shutdown); await server.connect(transport); } catch (error: unknown) {