I am trying to deploy a Next.js(next@12.0.8
) application on a production Linux server, Daemonize and load-balance it via pm2
npm module.
When I start the application in fork
mode all works fine.
The problem arises when I start it in a cluster mode with 4 instances. In this case only one instance is running and the rest of the instances are with "status=errored".
Node.js version = v16.13.2
Next.js version = 12.0.8
pm2 version = 5.1.2
and here is the ecosystem.config.js :
module.exports = {
apps : [{
name : "csr-next",
cwd: '/home/ruby/node/next-gen/',
script: 'npm',
args: 'start',
exec_mode : "cluster",
instances: 4
}],
};
Here is a demo video to demonstrate.
Checked the CPU(s) number on the host machine via $lscpu
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2