From 1cc159348a03550521244cc51154818ec0815ffc Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Tue, 19 Apr 2022 00:57:58 +0200 Subject: Use 1 thread on platform where fetching thread/core count fails --- api/src/start.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'api/src/start.ts') diff --git a/api/src/start.ts b/api/src/start.ts index 717e1b8f..ccb4d108 100644 --- a/api/src/start.ts +++ b/api/src/start.ts @@ -7,7 +7,12 @@ config(); import { FosscordServer } from "./Server"; import cluster from "cluster"; import os from "os"; -const cores = Number(process.env.THREADS) || os.cpus().length; +var cores = 1; +try { + cores = Number(process.env.THREADS) || os.cpus().length; +} catch { + console.log("[API] Failed to get thread count! Using 1...") +} if (cluster.isMaster && process.env.NODE_ENV == "production") { console.log(`Primary ${process.pid} is running`); -- cgit 1.4.1