当前位置:网站首页>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配置文件
边栏推荐
- Review of reflection topics
- js创建一个自定义json数组
- 微信小程序基础
- Date time API details
- Render minecraft scenes into real scenes using NVIDIA GPU
- Fe - use of weex development weex UI components and configuration use
- table 组件指定列合并行方法
- Queue (linear structure)
- Linux MySQL 5.6.51 Community Generic 安装教程
- There are multiple good constructors and room will problem
猜你喜欢
如何调试微信内置浏览器应用(企业号、公众号、订阅号)
In depth study of JVM bottom layer (V): class loading mechanism
Latex 报错 LaTeX Error: The font size command \normalsize is not defined问题解决
Latex compiles Chinese in vscode and solves the problem of using Chinese path
Vscode installation, latex environment, parameter configuration, common problem solving
There is no way to drag the win10 desktop icon (you can select it, open it, delete it, create it, etc., but you can't drag it)
sqli-labs通关汇总-page3
Huawei mindspire open source internship machine test questions
js中map和forEach的用法
Latest CUDA environment configuration (win10 + CUDA 11.6 + vs2019)
随机推荐
apt命令报证书错误 Certificate verification failed: The certificate is NOT trusted
Eggjs -typeorm treeenity practice
[literature reading and thought notes 13] unprocessing images for learned raw denoising
In depth study of JVM bottom layer (IV): class file structure
Selenium+msedgedriver+edge browser installation driver pit
Sublime text configuring PHP compilation environment
[daily question] - Huawei machine test 01
微信小程序基础
ModuleNotFoundError: No module named ‘jieba. analyse‘; ‘ jieba‘ is not a package
Date time API details
Latex warning: citation "*****" on page y undefined on input line*
Linux MySQL 5.6.51 Community Generic 安装教程
Latex error: the font size command \normalsize is not defined problem solved
解决微信小程序swiper组件bindchange事件抖动问题
web自动中利用win32上传附件
table 组件指定列合并行方法
Fe - use of weex development weex UI components and configuration use
Unexpected inconsistency caused by abnormal power failure; Run fsck manually problem resolved
Apt command reports certificate error certificate verification failed: the certificate is not trusted
Solution to the black screen of win computer screenshot