Commit evil (set process names)

This commit is contained in:
Rory&
2025-12-20 21:49:33 +01:00
parent 0b27fb5a79
commit 0b87ed9146
5 changed files with 21 additions and 1 deletions
+4
View File
@@ -26,6 +26,7 @@ config({ quiet: true });
import { SpacebarServer } from "./Server";
import cluster from "cluster";
import os from "os";
import fs from "fs";
let cores = 1;
try {
cores = Number(process.env.THREADS) || os.cpus().length;
@@ -48,6 +49,9 @@ if (cluster.isPrimary && process.env.NODE_ENV == "production") {
} else {
const port = Number(process.env.PORT) || 3001;
if (fs.existsSync("/proc/self/comm")) fs.writeFileSync("/proc/self/comm", `spacebar-api-${cluster.worker ? cluster.worker.id : port}`);
process.title = `sb-api-${cluster.worker ? cluster.worker.id : port}`;
const server = new SpacebarServer({ port });
server.start().catch(console.error);