import { openDb } from "./db"; import { startServer } from "./app"; // DATABASE_PATH comes from ~/app.env in production; the dev server uses ./dev.db. const db = openDb(process.env.DATABASE_PATH ?? "dev.db"); const { server, stop } = startServer(db, Number(process.env.PORT ?? 3000)); console.log(`Bun ${Bun.version} listening on ${server.url}`); // systemd sends SIGTERM on stop and restart: finish requests in flight, then exit. process.once("SIGTERM", async () => { await stop(); db.close(); process.exit(0); });