Use 1 thread on platform where fetching thread/core count fails

This commit is contained in:
TheArcaneBrony
2022-04-19 00:57:58 +02:00
parent c3f69bc6d8
commit 1cc159348a
3 changed files with 18 additions and 3 deletions
+6 -1
View File
@@ -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");