I have a pm2 managed app that runs in fork mode. How can I switch it to cluster mode?
You can take a look at this document.
Stop and delete your current app run on the pm2.
pm2 stop ${your app name}
pm2 delete ${your app name}
And rerun your app with arguments -i max:
pm2 start path/to/main.js -i max --name="${your app name}"
// Should use pm2 not pm
Or create a json config file and run your app with it
// processes.json
{
"your-app-name" : [{
"script" : "path/to/main.js",
"instances" : "max",
"exec_mode" : "cluster"
}]
}
pm2 start processes.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With