summary refs log tree commit diff
path: root/src/api/start.ts
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-12-17 11:00:51 +0100
committerRory& <root@rory.gay>2025-12-17 11:01:27 +0100
commit491c0de845a886954262e3ddb24959ba37a014b6 (patch)
treec0251f3779a5cd2842320e1278232b48fbea0390 /src/api/start.ts
parentPre-commit: use spaces for formatting, regenerate schemas if changed (diff)
downloadserver-ts-491c0de845a886954262e3ddb24959ba37a014b6.tar.xz
lintstagedrc: regenerate schemas/openapi if schemas changed
Diffstat (limited to 'src/api/start.ts')
-rw-r--r--src/api/start.ts34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/api/start.ts b/src/api/start.ts

index cd3373be..96c0c348 100644 --- a/src/api/start.ts +++ b/src/api/start.ts
@@ -28,30 +28,30 @@ import cluster from "cluster"; import os from "os"; let cores = 1; try { - cores = Number(process.env.THREADS) || os.cpus().length; + cores = Number(process.env.THREADS) || os.cpus().length; } catch { - console.log("[API] Failed to get thread count! Using 1..."); + console.log("[API] Failed to get thread count! Using 1..."); } if (cluster.isPrimary && process.env.NODE_ENV == "production") { - console.log(`Primary PID: ${process.pid}`); + console.log(`Primary PID: ${process.pid}`); - // Fork workers. - for (let i = 0; i < cores; i++) { - cluster.fork(); - } + // Fork workers. + for (let i = 0; i < cores; i++) { + cluster.fork(); + } - cluster.on("exit", (worker) => { - console.log(`Worker ${worker.process.pid} died, restarting worker`); - cluster.fork(); - }); + cluster.on("exit", (worker) => { + console.log(`Worker ${worker.process.pid} died, restarting worker`); + cluster.fork(); + }); } else { - const port = Number(process.env.PORT) || 3001; + const port = Number(process.env.PORT) || 3001; - const server = new SpacebarServer({ port }); - server.start().catch(console.error); + const server = new SpacebarServer({ port }); + server.start().catch(console.error); - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - global.server = server; + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + global.server = server; }