I have problems load balancing a Node.js (10.32) simple script using PM2, on a machine with two CPU cores.
The script is the following:
var http = require('http');
var server = http.createServer(function (req, res) {
res.writeHead(200, {"Content-Type": "text/plain"});
res.end("Hello World\n");
});
server.listen(81);
If I run pm2 start -i max script.js, the two child processes seem to launch successfully (according to pm2 list), but requests to http://localhost:81 hang.
If I run pm2 start -i max -x script.js, the first child process is successfully launched, but the second restarts forever (with an EADDRINUSE error).
I checked with lsof and the port 81 is not used before running PM2.