about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAlan Pearce2023-09-23 20:04:11 +0200
committerAlan Pearce2023-09-23 20:06:50 +0200
commita10cbf2a84411d66c46ea11587be5eb18ca4640e (patch)
tree8148a8f5dd3bb3410ee2e5558eb0d415656c4d83 /src
parent0e442791e6dc693f6f4587086967234f57580c91 (diff)
downloadwebsite-a10cbf2a84411d66c46ea11587be5eb18ca4640e.tar.lz
website-a10cbf2a84411d66c46ea11587be5eb18ca4640e.tar.zst
website-a10cbf2a84411d66c46ea11587be5eb18ca4640e.zip
Handle OS signals directly
Diffstat (limited to 'src')
-rw-r--r--src/index.ts12
1 files changed, 12 insertions, 0 deletions
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();
+});