• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question NodeJS Clustering on Plesk Onyx

Poh Kit

New Pleskian
Hello, I'm running an NodeJS application Plesks, everything works fine!
Somehow I'm trying to adapt Node Clustering into the server with below codes:

const cluster = require('cluster');
const http = require('http');
const numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
console.log(`Master ${process.pid} is running`);

// Fork workers.
for (let i = 0; i < numCPUs; i++) {
cluster.fork();
}

cluster.on('exit', (worker, code, signal) => {
console.log(`worker ${worker.process.pid} died`);
});
} else {
// Workers can share any TCP connection
// In this case it is an HTTP server
http.createServer((req, res) => {
res.writeHead(200);
res.end('hello world\n');
}).listen(8000);

console.log(`Worker ${process.pid} started`);
}

Anyhow, the variables cluster.isMaster return as False & numCPUs return as 3

This means that my server/plesk provider doesn't support above clustering module?
May I know how do I enabled/configure on Plesk panel admin to make this happen?

thanks!
 
Back
Top