Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between pm2 restart and pm2 reload

Tags:

node.js

pm2

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.

like image 955
Ayan Avatar asked Jul 03 '17 10:07

Ayan


People also ask

What is pm2 restart?

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.

Does pm2 auto restart?

PM2 will keep your application forever alive, auto-restarting across crashes and machine restarts.

Does pm2 auto restart after reboot?

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.

Does pm2 restart on file change?

Yes, pm2 restart picks up local changes. Clients may have to clear cache/refresh if you're not seeing the changes.


1 Answers

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.

like image 192
robertklep Avatar answered Sep 19 '22 11:09

robertklep