yiekheng 4a790b9a60 feat(bot): scaffold env, logger, db, health, shutdown
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-09 16:10:37 +08:00

26 lines
645 B
TypeScript

import { logger } from "./logger.js";
import { pool } from "./db.js";
import { startHealthServer } from "./health.js";
async function main(): Promise<void> {
logger.info("bot starting");
const health = startHealthServer();
const shutdown = async (signal: string): Promise<void> => {
logger.info({ signal }, "shutting down");
health.close();
await pool.end();
process.exit(0);
};
process.on("SIGINT", () => void shutdown("SIGINT"));
process.on("SIGTERM", () => void shutdown("SIGTERM"));
logger.info("bot ready");
}
main().catch((err) => {
logger.fatal({ err }, "bot failed to start");
process.exit(1);
});