2024-11-25 21:54:31 +01:00
|
|
|
import cluster from "node:cluster";
|
2025-04-10 19:56:42 +02:00
|
|
|
import process from "node:process";
|
2025-04-10 19:15:31 +02:00
|
|
|
import { Youch } from "youch";
|
2024-11-25 21:54:31 +01:00
|
|
|
import { sentry } from "@/sentry";
|
|
|
|
|
import { createServer } from "@/server";
|
|
|
|
|
import { appFactory } from "~/app";
|
2025-02-15 02:47:29 +01:00
|
|
|
import { config } from "~/config.ts";
|
2024-11-25 21:54:31 +01:00
|
|
|
|
|
|
|
|
process.on("SIGINT", () => {
|
|
|
|
|
process.exit();
|
|
|
|
|
});
|
|
|
|
|
|
2025-03-27 19:08:38 +01:00
|
|
|
process.on("uncaughtException", async (error) => {
|
|
|
|
|
const youch = new Youch();
|
|
|
|
|
|
|
|
|
|
console.error(await youch.toANSI(error));
|
|
|
|
|
});
|
|
|
|
|
|
2024-11-25 21:54:31 +01:00
|
|
|
if (cluster.isPrimary) {
|
|
|
|
|
for (let i = 0; i < Number(process.env.NUM_CPUS ?? 1); i++) {
|
|
|
|
|
cluster.fork();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await import("~/entrypoints/api/setup.ts");
|
|
|
|
|
sentry?.captureMessage("Server started", "info");
|
|
|
|
|
} else {
|
|
|
|
|
createServer(config, await appFactory());
|
|
|
|
|
}
|