• Plesk Uservoice will be deprecated by October. Moving forward, all product feature requests and improvement suggestions will be managed through our new platform Plesk Productboard.
    To continue sharing your ideas and feedback, please visit features.plesk.com

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