summary refs log tree commit diff
path: root/bundle
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-04-19 00:57:58 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-04-19 00:57:58 +0200
commit1cc159348a03550521244cc51154818ec0815ffc (patch)
tree04b3415f33046c02d4234859eac78fbdf8918c87 /bundle
parentgeneral rights enforcement stuff (diff)
downloadserver-1cc159348a03550521244cc51154818ec0815ffc.tar.xz
Use 1 thread on platform where fetching thread/core count fails
Diffstat (limited to 'bundle')
-rw-r--r--bundle/scripts/benchmark/connections.js7
-rw-r--r--bundle/src/start.ts7
2 files changed, 12 insertions, 2 deletions
diff --git a/bundle/scripts/benchmark/connections.js b/bundle/scripts/benchmark/connections.js
index 2a4125b4..ffca2628 100644
--- a/bundle/scripts/benchmark/connections.js
+++ b/bundle/scripts/benchmark/connections.js
@@ -3,8 +3,13 @@ const cluster = require("cluster");
 const WebSocket = require("ws");
 const endpoint = process.env.GATEWAY || "ws://localhost:3001";
 const connections = Number(process.env.CONNECTIONS) || 50;
-const threads = Number(process.env.THREADS) || require("os").cpus().length || 1;
 const token = process.env.TOKEN;
+var cores = 1;
+try {
+	cores = Number(process.env.THREADS) || os.cpus().length;
+} catch {
+	console.log("[Bundle] Failed to get thread count! Using 1...")
+}
 
 if (!token) {
 	console.error("TOKEN env var missing");
diff --git a/bundle/src/start.ts b/bundle/src/start.ts
index 7660b296..de3b5848 100644
--- a/bundle/src/start.ts
+++ b/bundle/src/start.ts
@@ -9,7 +9,12 @@ config();
 import { execSync } from "child_process";
 
 // TODO: add socket event transmission
-let 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) {
 	function getCommitOrFail() {