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
$ pm2 reload all # Reload all apps in cluster mode
$ pm2 gracefulReload all # Graceful reload all apps in cluster mode
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.