服务器启动脚本
PM2 has the amazing ability to generate startup scripts and configure them. PM2 is also smart enough to save all your process list and to bring back all your processes on restart.
$ pm2 startup [ubuntu|centos|gentoo|systemd]
Once you have started the apps and want to keep them on server reboot do:
$ pm2 save
警告 It's tricky to make this feature work generically, so once PM2 has setup your startup script, reboot your server to make sure that PM2 has launched your apps!
更多信息
Three types of startup scripts are available:
- SystemV init script (with the option
ubuntuorcentos) - OpenRC init script (with the option
gentoo) - SystemD init script (with the
systemdoption)
The startup options are using:
- ubuntu will use
updaterc.dand the scriptlib/scripts/pm2-init.sh - centos will use
chkconfigand the scriptlib/scripts/pm2-init-centos.sh - gentoo will use
rc-updateand the scriptlib/scripts/pm2 - systemd will use
systemctland the scriptlib/scripts/pm2.service
用户授权
Let's say you want the startup script to be executed under another user.
Just use the -u <username> option !
$ pm2 startup ubuntu -u www
相关命令
输出PM2管理的所有进程状态和环境:
$ pm2 dump
默认存入文件 ~/.pm2/dump.pm2.
找回最近的输出:
$ pm2 [resurrect|save]