2026-03-14 14:44:40 -05:00
|
|
|
import { createApp } from "./app.js";
|
|
|
|
|
import { env } from "./config/env.js";
|
|
|
|
|
import { bootstrapAppData } from "./lib/bootstrap.js";
|
|
|
|
|
import { prisma } from "./lib/prisma.js";
|
2026-03-15 14:57:41 -05:00
|
|
|
import { setLatestStartupReport } from "./lib/startup-state.js";
|
|
|
|
|
import { assertStartupReadiness } from "./lib/startup-validation.js";
|
2026-03-14 14:44:40 -05:00
|
|
|
|
|
|
|
|
async function start() {
|
|
|
|
|
await bootstrapAppData();
|
2026-03-15 14:57:41 -05:00
|
|
|
const startupReport = await assertStartupReadiness();
|
|
|
|
|
setLatestStartupReport(startupReport);
|
|
|
|
|
|
|
|
|
|
for (const check of startupReport.checks.filter((entry) => entry.status !== "PASS")) {
|
|
|
|
|
console.warn(`[startup:${check.status.toLowerCase()}] ${check.label}: ${check.message}`);
|
|
|
|
|
}
|
2026-03-14 14:44:40 -05:00
|
|
|
|
|
|
|
|
const app = createApp();
|
|
|
|
|
const server = app.listen(env.PORT, () => {
|
|
|
|
|
console.log(`MRP server listening on port ${env.PORT}`);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const shutdown = async () => {
|
|
|
|
|
server.close();
|
|
|
|
|
await prisma.$disconnect();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
process.on("SIGINT", shutdown);
|
|
|
|
|
process.on("SIGTERM", shutdown);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start().catch(async (error) => {
|
|
|
|
|
console.error(error);
|
|
|
|
|
await prisma.$disconnect();
|
|
|
|
|
process.exit(1);
|
|
|
|
|
});
|