Files
aetheel-2/src/shutdown-handler.ts

18 lines
452 B
TypeScript

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