What is the purpose of "pm2 save"?
Asked Answered
F

2

84

I am using pm2 to manage my node.js processes. Very happy with it so far.

What is the purpose of $ pm2 save? What is the purpose of saving a process list? I don't quite understand from the documentation. https://github.com/Unitech/pm2

Froemming answered 9/3, 2016 at 5:2 Comment(1)
Doing this will save the process list with their current environment into the dump file $PM2_HOME/.pm2/dump.pm2Ritualize
T
203

pm2 save takes a snapshot of your currently running Node applications. You can then restore these applications using pm2 resurrect.

This is useful because it means you don't have to manually restart each application when you restart pm2 (such as a machine reboot). Instead, you can just have a script that calls pm2 resurrect and it'll start up all the Node apps.

pm2 resurrect is useful to be called manually. If you want your processes to automatically start on boot, you should create a startup script with pm2 startup.

Thinkable answered 9/3, 2016 at 5:39 Comment(6)
Note pm2 resurrect is useful to be called manually. If you want your processes to automatically start on boot, you should create a startup script with pm2 startup. More info here: pm2.keymetrics.io/docs/usage/startupExcruciation
if we have multiple application running. Do you know in what order after running resurrect? I have not been able to find out in any documentationScofield
save is hidden behind dump if you are looking for it in the helpLansquenet
The term "snapshot" is misleading and makes you overthink on what it does. PM2 simply describes it as "save the app list".Maybellmaybelle
Note: pm2 save dumps the list of running apps to ~/pm2/dump.pm2, and the script generated by pm2 startup uses it to run the apps when the server is rebooted.Cristincristina
pm2 startup is usefull, but what if my user is NOT a SUDO and I do not want the sudo to uses pm2 at all. I havve a dedicated user for these jobs, but seemingly if I execute the sscript provided by the command (without the SUDO part), it just repeats itself. IDK if it actually made it work or notBottommost
R
18

$ pm2 save is used to save the pm2 process list to relaunch them after a server reboot. It comes generaly with :

pm2 startup which generates Startup Script

Receptacle answered 11/11, 2019 at 12:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.