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