当前位置:网站首页>PM2 simple use and daemon
PM2 simple use and daemon
2022-07-02 06:59:00 【Snow wind in the night sky】
Preface : This tutorial uses centos8 As an example , Other systems can be replaced by themselves .
One 、 install
1. install nodejs
yum install nodejs
2. install pm2
cd /root && npm install pm2 -g
3. Check for successful installation
pm2 list
Two 、 Use
1. A daemon / Script
pm2 start Your program name
2. The guardian thread / process
pm2 start ' Your progress / Threads '
3. Boot from boot
After all the guards are finished, you can run it automatically if you want to turn it on , After all, it's still troublesome to start one by one .
pm2 ps ## Check whether the list you are guarding is correct
4. Stop those who don't want to start up automatically
pm2 stop Your program /' process '
5. Save the services enabled in the current list
pm2 save
6. Add the service that has just been started in the keep list to the startup self startup
sudo pm2 startup
7. How to delete startup ( You cannot delete an item alone )
pm2 unstartup systemd
3、 ... and 、 Troubleshooting
1. Check whether it is administrator mode , If it is not :
su -root
2. Update instruction Library
yum update
3. uninstall
yum remove nodejs -y
Four 、 other
upgrade pm2
pm2 update
5、 ... and 、 Cluster mode ( Limited to Node.js)
pm2 start app.js -i 4 ## Start in cluster mode 4 Application instances , It will load balance each application's network queries
pm2 reload all ## Zero second shutdown and restart
pm2 scale [app-name] 10 ## Scale clustering is applied to 10 A process
## Process monitoring
pm2 list ## List PM2 All processes
pm2 monit ## Displays the memory of each application and cpu usage
pm2 show [app-name] ## Show all the information about the application
## Log management
pm2 logs ## Show logs for all applications
pm2 logs [app-name] ## Show logs for a specific application
pm2 logs --json ## journal JSON format
pm2 flush
pm2 reloadLogs
## Process status management
pm2 start app.js --name="233" ## Start the application and name it “233”
pm2 start app.js -- -a 343 ## Start applying and passing options “-a 343” As a parameter
pm2 start app.js --watch ## Restart the file change application
pm2 start script.sh ## start-up bash Type scripts
pm2 start app.json ## Start at app.json All applications declared in
pm2 reset [app-name] ## Reset all counters
pm2 stop all ## Stop all applications
pm2 stop 456 ## Stop the process id by 456 Applications for
pm2 restart all ## Restart all applications
pm2 gracefulReload all ## Reload all applications normally in cluster mode
pm2 delete all ## Kill and delete all applications
pm2 delete 114 ## Delete process id by 114 Applications for
## start-up / Guide management
pm2 resurrect ## Restore the previously saved process
pm2 unstartup ## Disable and delete the boot system
pm2 update ## Save process , Kill PM2 And resume the process
pm2 generate ## Generate an example json The configuration file
边栏推荐
猜你喜欢

SQLI-LABS通關(less6-less14)

flex九宫格布局

VSCODE 安装LATEX环境,参数配置,常见问题解决

Linux MySQL 5.6.51 community generic installation tutorial

SQL injection closure judgment

Cve - 2015 - 1635 (ms15 - 034) réplication de la vulnérabilité d'exécution de code à distance

SQLI-LABS通关(less6-less14)

Sublime text configuring PHP compilation environment

The use of regular expressions in JS

由於不正常斷電導致的unexpected inconsistency;RUN fsck MANUALLY問題已解决
随机推荐
How to try catch statements that return promise objects in JS
js删除字符串的最后一个字符
VSCODE 安装LATEX环境,参数配置,常见问题解决
JS countdown case
sprintf_ How to use s
微信小程序基础
In depth study of JVM bottom layer (V): class loading mechanism
Stress test modification solution
Eggjs -typeorm treeenity practice
Tool grass welfare post
php中生成随机的6位邀请码
Deployment API_ automation_ Problems encountered during test
sqli-labs通關匯總-page2
Use of interrupt()
JS create a custom JSON array
如何调试微信内置浏览器应用(企业号、公众号、订阅号)
UEditor .Net版本任意文件上传漏洞复现
PgSQL learning notes
Win10网络图标消失,网络图标变成灰色,打开网络设置闪退等问题解决
20210306 reprint how to make TextEdit have background pictures