Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pm2 difference between stop and delete app

Tags:

node.js

pm2

In pm2 node app manager, what is the difference between stop and delete app. I know that delete app deletes the app, from the pm2:s control, but what does stop app do? They both will set node server to offline.

My problem is that during deployment, if I want to pull code, and then restart the node server, then which pm2 commands to use? What I have done now is first pm2 stop app -> pull code -> pm2 start app. But how do I know that the app.js is really updated? What if stop puts the app in memory, and loads it there? So after start, it will start the previous version, and not from the code that was pulled.

like image 348
Ville Miekk-oja Avatar asked May 29 '16 13:05

Ville Miekk-oja


1 Answers

Stop command keeps the app in the Apps list, delete command not. You can see the Apps list with the command:

pm2 status 

So if you stopped, you can restart your app just by its name.

I think the command you want is:

pm2 reload [AppName]

Just replace the files and then run the command.

Source: http://pm2.keymetrics.io/docs/usage/pm2-doc-single-page/

You can handle the reload signal inside you app, what could be interesting in production. More info: http://pm2.keymetrics.io/docs/usage/signals-clean-restart/

like image 192
Gianfranco Meneguz Avatar answered Sep 19 '22 07:09

Gianfranco Meneguz