feat(gateway): add child cleanup to shutdown sequence
This commit is contained in:
parent
6f692363fb
commit
2ed6eb005c
@ -3,6 +3,7 @@ import type { WebSocketServer } from "ws";
|
|||||||
import type { CanvasHostHandler, CanvasHostServer } from "../canvas-host/server.js";
|
import type { CanvasHostHandler, CanvasHostServer } from "../canvas-host/server.js";
|
||||||
import { type ChannelId, listChannelPlugins } from "../channels/plugins/index.js";
|
import { type ChannelId, listChannelPlugins } from "../channels/plugins/index.js";
|
||||||
import { stopGmailWatcher } from "../hooks/gmail-watcher.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 { HeartbeatRunner } from "../infra/heartbeat-runner.js";
|
||||||
import type { PluginServicesHandle } from "../plugins/services.js";
|
import type { PluginServicesHandle } from "../plugins/services.js";
|
||||||
|
|
||||||
@ -124,5 +125,11 @@ export function createGatewayCloseHandler(params: {
|
|||||||
httpServer.close((err) => (err ? reject(err) : resolve())),
|
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();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user