1
0
Fork 0
forked from svrjs/svrjs

Use os.availableParallelism if it is implemented

This commit is contained in:
Dorian Niemiec 2024-04-21 19:39:30 +02:00
parent 1ae35a1977
commit a986d3c523

4
svr.js
View file

@ -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...