I have a nodejs app running on server.
When should I use pm2 restart,and when should pm2 reload be used?
Referred to the pm2 documention here,but couldn't figure out the difference in use case of the two.
PM2 allows to reload (auto fallback to restart if not in cluster) an application based on a memory limit/ Please note that the PM2 internal worker (which checks memory), starts every 30 seconds, so you may have to wait a bit before your process gets restarted automatically after reaching the memory threshold.
PM2 will keep your application forever alive, auto-restarting across crashes and machine restarts.
The start script sets up PM2 as a service under the init system. When the server restarts, it will automatically restart PM2, which will then restart all the Node. js applications/processes it is managing. In this article, we will show you how to deploy PM2 as a service to reliably manage your Node.
Yes, pm2 restart picks up local changes. Clients may have to clear cache/refresh if you're not seeing the changes.
The difference is documented here:
As opposed to
restart
, which kills and restarts the process,reload
achieves a 0-second-downtime reload.
The latter means (found here):
With reload,
pm2
restarts all processes one by one, always keeping at least one process running.
It also states that:
If the reload system hasn’t managed to reload your application, a timeout will fallback to a classic restart.
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