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")); }