当前位置:网站首页>pm2简单使用和守护进程
pm2简单使用和守护进程
2022-07-02 06:23:00 【夜空の雪風】
前言:本教程以centos8为例子,其他系统可自行替换。
一、安装
1.安装nodejs
yum install nodejs
2.安装pm2
cd /root && npm install pm2 -g
3.检查是否成功安装
pm2 list
二、使用
1.守护程序/脚本
pm2 start 你的程序名
2.守护线程/进程
pm2 start '你的进程/线程'
3.开机自启
全部守护完后想要开机就自动运行吧,毕竟一条一条去启动还是很麻烦的。
pm2 ps ##查看你守护的列表是否正确
4.停止不想开机自启的
pm2 stop 你的程序/'进程'
5.保存当前列表启用的服务
pm2 save
6.将刚才保持列表中启动的服务加入开机自启
sudo pm2 startup
7.如何删除开机自启(不能单独删除某项)
pm2 unstartup systemd
三、故障排除
1.检查是否是管理员模式,若不是:
su -root
2.更新指令库
yum update
3.卸载
yum remove nodejs -y
四、其他
升级pm2
pm2 update
五、群集模式(仅限Node.js)
pm2 start app.js -i 4 ## 在群集模式下启动4个应用程序实例,它将负载平衡每个应用程序的网络查询
pm2 reload all ##零秒停机重启
pm2 scale [app-name] 10 ##规模集群应用到10个进程
##进程监控
pm2 list ##列出PM2所有流程
pm2 monit ##显示每个应用程序的内存和cpu使用情况
pm2 show [app-name] ##显示相关应用程序的所有信息
##日志管理
pm2 logs ##显示所有应用程序的日志
pm2 logs [app-name] ##显示特定应用程序的日志
pm2 logs --json ##日志JSON格式化
pm2 flush
pm2 reloadLogs
##进程状况管理
pm2 start app.js --name="233" ##启动应用程序并将其命名为“233”
pm2 start app.js -- -a 343 ##开始应用并传递选项“-a 343”作为参数
pm2 start app.js --watch ##重新启动文件更改应用程序
pm2 start script.sh ##启动bash类型脚本
pm2 start app.json ##启动在app.json中声明的所有应用程序
pm2 reset [app-name] ##重置所有计数器
pm2 stop all ##停止所有应用程序
pm2 stop 456 ##停止进程id为456的应用程序
pm2 restart all ##重启所有应用程序
pm2 gracefulReload all ##以群集模式正常重新加载所有应用程序
pm2 delete all ##杀死并删除所有应用程序
pm2 delete 114 ##删除进程id为114的应用程序
##启动/引导管理
pm2 resurrect ##恢复以前保存的进程
pm2 unstartup ##禁用并删除启动系统
pm2 update ##保存进程,杀死PM2并恢复进程
pm2 generate ##生成一个示例json配置文件
边栏推荐
- [Zhang San learns C language] - deeply understand data storage
- 浏览器滚动加载更多实现
- JS divides an array into groups of three
- web自动化切换窗口时报错“list“ object is not callable
- 蚂蚁集团g6初探
- Wechat applet Foundation
- unittest. Texttestrunner does not generate TXT test reports
- Latex compilation error I found no \bibstyle &\bibdata &\citation command
- Utilisation de la carte et de foreach dans JS
- Improve user experience defensive programming
猜你喜欢

Unexpected inconsistency caused by abnormal power failure; Run fsck manually problem resolved

Explanation and application of annotation and reflection

微信小程序基础

CVE-2015-1635(MS15-034 )遠程代碼執行漏洞複現

Warp shuffle in CUDA

Stack (linear structure)

apt命令报证书错误 Certificate verification failed: The certificate is NOT trusted

The default Google browser cannot open the link (clicking the hyperlink does not respond)

uniapp引入本地字体

VSCODE 安装LATEX环境,参数配置,常见问题解决
随机推荐
Anti shake and throttling of JS
Storage space modifier in CUDA
js数组的常用的原型方法
Latex在VSCODE中编译中文,使用中文路径问题解决
uniapp引入本地字体
Fe - weex uses a simple encapsulated data loading plug-in as the global loading method
Win10桌面图标没有办法拖动(可以选中可以打开可以删除新建等操作但是不能拖动)
看完有用的blog
Win10网络图标消失,网络图标变成灰色,打开网络设置闪退等问题解决
Win电脑截图黑屏解决办法
Overload global and member new/delete
js的防抖和节流
sqli-labs通关汇总-page3
查询GPU时无进程运行,但是显存却被占用了
The win10 network icon disappears, and the network icon turns gray. Open the network and set the flash back to solve the problem
ts和js区别
Solve the problem of bindchange event jitter of swiper component of wechat applet
由于不正常断电导致的unexpected inconsistency;RUN fsck MANUALLY问题已解决
Redis -- cache breakdown, penetration, avalanche
Apt command reports certificate error certificate verification failed: the certificate is not trusted