MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / stopAutoSpawnedDaemon

Function stopAutoSpawnedDaemon

e2e/local/daemon-process.ts:38–55  ·  view source on GitHub ↗
(dataDir: string)

Source from the content-addressed store, hash-verified

36
37/** Stop the detached daemon elected by an `executor mcp` cold start. */
38export const stopAutoSpawnedDaemon = async (dataDir: string): Promise<void> => {
39 // oxlint-disable-next-line executor/no-try-catch-or-throw -- cleanup tolerates a bridge that failed before writing its manifest
40 try {
41 const manifest = JSON.parse(
42 await readFile(join(dataDir, "server-control", "server.json"), "utf8"),
43 ) as { readonly pid?: unknown };
44 if (!Number.isSafeInteger(manifest.pid) || (manifest.pid as number) <= 0) return;
45
46 const pid = manifest.pid as number;
47 signal(pid, "SIGTERM");
48 if (await waitUntilStopped(pid, 10_000)) return;
49
50 signal(pid, "SIGKILL");
51 await waitUntilStopped(pid, 2_000);
52 } catch {
53 // No manifest means there is no auto-started daemon to stop.
54 }
55};

Calls 2

signalFunction · 0.85
waitUntilStoppedFunction · 0.85

Tested by

no test coverage detected