Initial commit: Discord-Claude Gateway with event-driven agent runtime
This commit is contained in:
17
src/shutdown-handler.ts
Normal file
17
src/shutdown-handler.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { GatewayCore } from "./gateway-core.js";
|
||||
|
||||
export function registerShutdownHandler(gateway: GatewayCore): void {
|
||||
let shuttingDown = false;
|
||||
|
||||
const handler = (signal: string) => {
|
||||
if (shuttingDown) {
|
||||
return;
|
||||
}
|
||||
shuttingDown = true;
|
||||
console.log(`Received ${signal}, shutting down...`);
|
||||
gateway.shutdown();
|
||||
};
|
||||
|
||||
process.on("SIGTERM", () => handler("SIGTERM"));
|
||||
process.on("SIGINT", () => handler("SIGINT"));
|
||||
}
|
||||
Reference in New Issue
Block a user