feat(gateway): add child cleanup to shutdown sequence

This commit is contained in:
Trevin Chow 2026-01-29 12:34:12 -08:00 committed by Trevin Chow
parent 6f692363fb
commit 2ed6eb005c

View File

@ -3,6 +3,7 @@ import type { WebSocketServer } from "ws";
import type { CanvasHostHandler, CanvasHostServer } from "../canvas-host/server.js";
import { type ChannelId, listChannelPlugins } from "../channels/plugins/index.js";
import { stopGmailWatcher } from "../hooks/gmail-watcher.js";
import { killAllChildren, killAllChildrenSync } from "../infra/child-registry.js";
import type { HeartbeatRunner } from "../infra/heartbeat-runner.js";
import type { PluginServicesHandle } from "../plugins/services.js";
@ -124,5 +125,11 @@ export function createGatewayCloseHandler(params: {
httpServer.close((err) => (err ? reject(err) : resolve())),
);
}
// Phase 3: Kill any orphaned children not stopped by their own managers
await killAllChildren("SIGTERM", { excludeManaged: true, timeoutMs: 2000 });
// Phase 4: Force cleanup of any remaining children
killAllChildrenSync();
};
}