import bunextInit from "../../functions/bunext-init"; import startServer from "../../functions/server/start-server"; import { log } from "../../utils/log"; import writeErrorFile from "../../functions/write-error-file"; // Same crash contract as the dev child: log the real error, record it in the // error file, and exit non-zero so the supervisor can restart and so the // bundler pipeline sees the failure. process.on("uncaughtException", (error) => { log.error(`Uncaught exception: ${error}`); writeErrorFile({ error, exitCode: 1, force: true }); process.exit(1); }); process.on("unhandledRejection", (reason) => { log.error(`Unhandled rejection: ${reason}`); writeErrorFile({ error: reason, exitCode: 1, force: true }); process.exit(1); }); log.info("Starting production server ..."); try { await bunextInit(); await startServer(); } catch (error) { log.error(`Failed to start production server: ${error}`); writeErrorFile({ error, exitCode: 1, force: true }); process.exit(1); }