当前位置:网站首页>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配置文件
边栏推荐
- Sqli labs customs clearance summary-page3
- Wechat applet Foundation
- Fe - wechat applet - Bluetooth ble development research and use
- js中对于返回Promise对象的语句如何try catch
- Solve the problem of bindchange event jitter of swiper component of wechat applet
- JS delete the last bit of the string
- Error "list" object is not callable in Web automatic switching window
- Recursion (maze problem, Queen 8 problem)
- 2020-9-23 use of QT timer qtimer class.
- Overload global and member new/delete
猜你喜欢
Self study table Au
Uploading attachments using Win32 in Web Automation
Sentry搭建和使用
【文献阅读与想法笔记13】 Unprocessing Images for Learned Raw Denoising
In depth study of JVM bottom layer (II): hotspot virtual machine object
No process runs when querying GPU, but the video memory is occupied
Win电脑截图黑屏解决办法
Recursion (maze problem, Queen 8 problem)
Latex参考文献引用失败 报错 LaTeX Warning: Citation “*****” on page y undefined on input line *
Latex compiles Chinese in vscode and solves the problem of using Chinese path
随机推荐
Linux MySQL 5.6.51 Community Generic 安装教程
Sentry construction and use
Common prototype methods of JS array
selenium备忘录:selenium\webdriver\remote\remote_connection.py:374: ResourceWarning: unclosed<xxxx>解决办法
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)
AWD learning
selenium的web自动化中常用的js-修改元素属性翻页
PIP install
Flask migrate cannot detect db String() equal length change
The use of regular expressions in JS
js中对于返回Promise对象的语句如何try catch
flex九宫格布局
Code execution sequence with and without resolve in promise
JS delete the last bit of the string
Stack (linear structure)
Uniapp introduces local fonts
Latest CUDA environment configuration (win10 + CUDA 11.6 + vs2019)
Build learning tensorflow
QQ email cannot receive the email sent by Jenkins using email extension after construction (timestamp or auth...)
Functions of tensorrt