From a10cbf2a84411d66c46ea11587be5eb18ca4640e Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sat, 23 Sep 2023 20:04:11 +0200 Subject: Handle OS signals directly --- src/index.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/index.ts') diff --git a/src/index.ts b/src/index.ts index c18ebb2..bb492d0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,3 +9,15 @@ console.info(`Metrics server started on port ${metricsServed.port}`); const served = Bun.serve(server); console.info(`Serving website on http://${served.hostname}:${served.port}/`); + +process.on("SIGTERM", function () { + log.info("SIGTERM received, shutting down..."); + metricsServed.stop(); + served.stop(); +}); + +process.on("SIGINT", function () { + log.info("SIGINT received, shutting down..."); + metricsServed.stop(); + served.stop(); +}); -- cgit 1.4.1