Dough Git

commit

Fixes

commit
3b11528b513cca20d4c14ab5159bfb063dc4ba01
author
Clove Twilight <[email protected]>
date
2026-11-12 19:02

diff --git a/deploy/run b/deploy/run
index e8676ee..167eaf9 100755
--- a/deploy/run
+++ b/deploy/run
@@ -3,7 +3,7 @@
 # MIT — (c) Doughmination System®
 exec 2>&1
 
-cd /srv/clove/is-a-tracker || exit 1
+cd /srv/clove/isATracker || exit 1
 
 export HOST=127.0.0.1
 export PORT=3101
@@ -13,7 +13,7 @@ export NODE_ENV=production
 export HOME=/home/clove
 
 # Secrets (GitHub token, Discord bot token, dashboard password) and ORIGIN live in
-# /srv/clove/is-a-tracker/.env, which Deno skips if it's missing.
+# /srv/clove/isATracker/.env, which Deno skips if it's missing.
 # ORIGIN must be the dashboard's public URL: SvelteKit needs it for form actions (CSRF check)
 
 # Reads are limited to this folder; writes are limited to data/, where the SQLite file lives
diff --git a/src/lib/server/runtime.ts b/src/lib/server/runtime.ts
index cbf680d..e86e8d4 100644
--- a/src/lib/server/runtime.ts
+++ b/src/lib/server/runtime.ts
@@ -19,8 +19,28 @@ interface RuntimeHandle {
 // Kept on globalThis so a dev-server reload replaces the services instead of doubling them
 const globalStore = globalThis as typeof globalThis & {
 	trackerRuntime?: RuntimeHandle;
+	trackerShutdownHooked?: boolean;
 };
 
+// The Node adapter closes the web server on SIGTERM or SIGINT, then emits this event.
+// The Discord connection and the scanner timer would otherwise keep the process alive.
+function hookShutdown(): void {
+	if (globalStore.trackerShutdownHooked) {
+		return;
+	}
+
+	globalStore.trackerShutdownHooked = true;
+
+	process.on('sveltekit:shutdown', (reason: string) => {
+		logger.info(`Stopping (${reason})`);
+
+		void globalStore.trackerRuntime
+			?.stop()
+			.catch((error) => logger.warn('Clean stop failed', error))
+			.finally(() => process.exit(0));
+	});
+}
+
 async function stop(): Promise<void> {
 	stopScanner();
 	removeFindingListeners();
@@ -32,6 +52,8 @@ export async function startServices(): Promise<void> {
 
 	globalStore.trackerRuntime = { stop };
 
+	hookShutdown();
+
 	const config = getConfig();
 
 	getDatabase();