Auto-sync: 2026-04-17 08:37

This commit is contained in:
2026-04-17 08:38:12 +08:00
parent 6caa1c2f47
commit a0a48bd334
247 changed files with 6577 additions and 3061 deletions

38
wiki/concepts/pm2.md Normal file
View File

@@ -0,0 +1,38 @@
---
title: "pm2"
type: concept
tags: [node-js, process-manager, devops]
last_updated: 2026-04-17
---
## 定义
pm2 是 Node.js 进程管理器,提供进程守护、日志管理、负载均衡和开机自启等功能。
## 用途
- 守护 Node.js 进程,保持持续运行
- 管理系统日志
- 实现进程崩溃后自动重启
- 配置开机自启动
- 负载均衡cluster 模式)
## 安装方法
```bash
npm install -g pm2
```
## 常用命令
```bash
pm2 start <script> --name <name> # 启动进程
pm2 status # 查看状态
pm2 logs <name> # 查看日志
pm2 restart <name> # 重启进程
pm2 stop <name> # 停止进程
pm2 delete <name> # 删除进程
pm2 save # 保存当前进程列表
pm2 startup systemd # 生成自启动脚本
```
## 关联
- 配合工具:[[npm]]
- 管理对象:[[Node-js]]
- 替代工具forever、supervisor