From a986d3c523ad266e72fd74bc4eab1b2d305a1be2 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 21 Apr 2024 19:39:30 +0200 Subject: [PATCH] Use os.availableParallelism if it is implemented --- svr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svr.js b/svr.js index 7ab9945..5b01f8b 100644 --- a/svr.js +++ b/svr.js @@ -5300,7 +5300,7 @@ function start(init) { if (stopError) serverconsole.climessage("Some SVR.JS workers might not be stopped."); SVRJSInitialized = false; closedMaster = true; - var cpus = os.cpus().length; + var cpus = os.availableParallelism ? os.availableParallelism() : os.cpus().length; if (cpus > 16) cpus = 16; try { var useAvailableCores = Math.round((os.freemem()) / 50000000) - 1; // 1 core deleted for safety... @@ -5371,7 +5371,7 @@ function start(init) { if (cluster.isPrimary || cluster.isPrimary === undefined) { // Cluster forking code if (cluster.isPrimary !== undefined && init) { - var cpus = os.cpus().length; + var cpus = os.availableParallelism ? os.availableParallelism() : os.cpus().length; if (cpus > 16) cpus = 16; try { var useAvailableCores = Math.round((os.freemem()) / 50000000) - 1; // 1 core deleted for safety...