From e8feb4d35e982a92d6c80ece3d4f46db81a51589 Mon Sep 17 00:00:00 2001 From: bompus Date: Fri, 23 Oct 2026 10:58:05 -0600 Subject: [PATCH] fix(wake): wake-auto-t3 logs the signal that stops it On SIGTERM or SIGINT the supervisor aborted and returned 0 without a log line, so a signal sent by anything other than the service manager looked like a normal stop in the journal. It now logs the signal name once before shutdown. Closes #187. --- CHANGELOG.md | 3 +++ src/wake-auto-t3.ts | 15 ++++++++++----- test/wake-auto-t3.test.ts | 4 +++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 83e63da..f3ca161 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Notable changes to Swarmail. Versions follow [semantic versioning](https://semve ## Unreleased +- `swarmail wake-auto-t3` logs `received SIGTERM; stopping` (or `SIGINT`) when it receives the signal, so a + signalled stop no longer looks like a silent exit 0 in the journal. + - The provider comparison covers T3 Code 0.1.1 and the reviewed nightly's terminal commands, pull-request lookup limits and automatic-notice snooze behavior. diff --git a/src/wake-auto-t3.ts b/src/wake-auto-t3.ts index 30f969c..b349e57 100644 --- a/src/wake-auto-t3.ts +++ b/src/wake-auto-t3.ts @@ -632,9 +632,14 @@ export async function wakeAutoT3(args: string[]): Promise { return 64; } const abort = new AbortController(); - const stop = () => abort.abort(); - process.once("SIGTERM", stop); - process.once("SIGINT", stop); + const stopOn = (signalName: string) => () => { + console.error(`swarmail wake-auto-t3: received ${signalName}; stopping`); + abort.abort(); + }; + const onTerm = stopOn("SIGTERM"); + const onInt = stopOn("SIGINT"); + process.once("SIGTERM", onTerm); + process.once("SIGINT", onInt); let lock: ReturnType | undefined; let failures = new Map(); let failuresLoaded = false; @@ -686,7 +691,7 @@ export async function wakeAutoT3(args: string[]): Promise { lock.close(); } } - process.removeListener("SIGTERM", stop); - process.removeListener("SIGINT", stop); + process.removeListener("SIGTERM", onTerm); + process.removeListener("SIGINT", onInt); } } diff --git a/test/wake-auto-t3.test.ts b/test/wake-auto-t3.test.ts index 6900b7b..b41479b 100644 --- a/test/wake-auto-t3.test.ts +++ b/test/wake-auto-t3.test.ts @@ -1474,7 +1474,9 @@ test("automatic supervisor waits out a T3 restart and follows its new port", asy await stalled?.stop(true); f.close(); } - expect(await errors).toContain("T3 backend unavailable; waiting for verified readiness"); + const log = await errors; + expect(log).toContain("T3 backend unavailable; waiting for verified readiness"); + expect(log.match(/swarmail wake-auto-t3: received SIGTERM; stopping/g)).toHaveLength(1); }, 30000); test("automatic scans repeat only after a T3 commit, a registry write, a reopen or the rescan interval", () => {