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."); if (stopError) serverconsole.climessage("Some SVR.JS workers might not be stopped.");
SVRJSInitialized = false; SVRJSInitialized = false;
closedMaster = true; closedMaster = true;
var cpus = os.cpus().length; var cpus = os.availableParallelism ? os.availableParallelism() : os.cpus().length;
if (cpus > 16) cpus = 16; if (cpus > 16) cpus = 16;
try { try {
var useAvailableCores = Math.round((os.freemem()) / 50000000) - 1; // 1 core deleted for safety... 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) { if (cluster.isPrimary || cluster.isPrimary === undefined) {
// Cluster forking code // Cluster forking code
if (cluster.isPrimary !== undefined && init) { if (cluster.isPrimary !== undefined && init) {
var cpus = os.cpus().length; var cpus = os.availableParallelism ? os.availableParallelism() : os.cpus().length;
if (cpus > 16) cpus = 16; if (cpus > 16) cpus = 16;
try { try {
var useAvailableCores = Math.round((os.freemem()) / 50000000) - 1; // 1 core deleted for safety... var useAvailableCores = Math.round((os.freemem()) / 50000000) - 1; // 1 core deleted for safety...