当前位置:网站首页>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配置文件
边栏推荐
- 2020-9-23 use of QT timer qtimer class.
- The use of regular expressions in JS
- Apt command reports certificate error certificate verification failed: the certificate is not trusted
- 【文献阅读与想法笔记13】 Unprocessing Images for Learned Raw Denoising
- selenium备忘录:selenium\webdriver\remote\remote_connection.py:374: ResourceWarning: unclosed<xxxx>解决办法
- PHP Session原理简析
- Sublime text configuring PHP compilation environment
- Uniapp introduces local fonts
- Flex Jiugongge layout
- Vscode installation, latex environment, parameter configuration, common problem solving
猜你喜欢

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

The table component specifies the concatenation parallel method

如何调试微信内置浏览器应用(企业号、公众号、订阅号)

Review of reflection topics

SQLI-LABS通关(less15-less17)

SQL注入闭合判断

Sentry搭建和使用

微信小程序基础
![[literature reading and thought notes 13] unprocessing images for learned raw denoising](/img/a5/ed26a90b3edd75a37b2e5164f6b7d2.png)
[literature reading and thought notes 13] unprocessing images for learned raw denoising

Win10网络图标消失,网络图标变成灰色,打开网络设置闪退等问题解决
随机推荐
Improve user experience defensive programming
selenium+msedgedriver+edge浏览器安装驱动的坑
JS countdown case
Fe - eggjs combined with typeorm cannot connect to the database
VSCODE 安装LATEX环境,参数配置,常见问题解决
Stress test modification solution
查询GPU时无进程运行,但是显存却被占用了
工具种草福利帖
Differences between ts and JS
Uploading attachments using Win32 in Web Automation
Huawei mindspire open source internship machine test questions
Loops in tensorrt
Wechat applet Foundation
JS to determine whether there is a value in the object in the array
Solution to the black screen of win computer screenshot
js把一个数组分割成每三个一组
PgSQL learning notes
Sqli labs customs clearance summary-page3
In depth study of JVM bottom layer (3): garbage collector and memory allocation strategy
Vector types and variables built in CUDA