From 84fdd3801aae3de9c4c3c28e893ba85e09131c04 Mon Sep 17 00:00:00 2001 From: eneller Date: Sun, 2 Aug 2026 13:06:22 +0200 Subject: [PATCH] chore: fix dev script --- server/src/scripts/dev.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/scripts/dev.ts b/server/src/scripts/dev.ts index 913e30e..ca64391 100644 --- a/server/src/scripts/dev.ts +++ b/server/src/scripts/dev.ts @@ -2,6 +2,8 @@ //Runs `npm run dev-bg` and listens for interrupts to execute `npm run teardown` import { spawn } from "node:child_process"; +let isShuttingDown = false; + const child = spawn("npm", ["run", "dev-bg"], { stdio: "inherit", shell: true, @@ -12,12 +14,15 @@ async function teardown() { const teardownProcess = spawn("npm", ["run", "teardown"], { stdio: "inherit", shell: true, + detached: true }); await new Promise((resolve) => teardownProcess.on("exit", resolve)); } async function shutdown(signal: any) { + if(isShuttingDown) return; + isShuttingDown = true; child.kill(signal); await teardown(); process.exit(); @@ -27,6 +32,5 @@ process.on("SIGINT", () => shutdown("SIGINT")); process.on("SIGTERM", () => shutdown("SIGTERM")); child.on("exit", async (code) => { - await teardown(); process.exit(code ?? 0); });