import { closeInboundQueue } from "./queue"; import { startServer } from "./server"; const server = startServer(); async function shutdown(signal: string) { console.log(`[omni_inbound] shutting down by ${signal}`); try { await new Promise((resolve, reject) => { server.close((error) => { if (error) { reject(error); return; } resolve(); }); }); } catch { // ignore shutdown errors } try { await closeInboundQueue(); } catch { // ignore shutdown errors } process.exit(0); } process.on("SIGINT", () => { void shutdown("SIGINT"); }); process.on("SIGTERM", () => { void shutdown("SIGTERM"); });