docs: add PM2 one-click start
This commit is contained in:
50
README.md
50
README.md
@@ -55,8 +55,16 @@ https://github.com/ZgDaniel/cc-web 给我装!
|
||||
```bash
|
||||
git clone https://github.com/ZgDaniel/cc-web.git
|
||||
cd cc-web
|
||||
npm install
|
||||
cp .env.example .env # 可选,不设密码则首次启动自动生成
|
||||
./start.sh
|
||||
```
|
||||
|
||||
`start.sh` 会检查 Node.js/npm 环境,自动安装 PM2(如未安装),安装项目依赖,并以 `ccweb` 为默认应用名启动或重启服务。
|
||||
|
||||
如只想前台临时运行,也可以手动执行:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
@@ -137,6 +145,7 @@ cc-web/
|
||||
│ ├── mock-claude.js # 回归用 mock Claude CLI
|
||||
│ └── mock-codex.js # 回归用 mock Codex CLI
|
||||
├── .env.example # 环境变量模板
|
||||
├── start.sh # Linux / macOS PM2 一键启动脚本
|
||||
├── start.bat # Windows 一键启动脚本
|
||||
├── .gitignore
|
||||
├── package.json
|
||||
@@ -186,6 +195,45 @@ tail -f logs/process.log | jq .
|
||||
|
||||
## 生产部署
|
||||
|
||||
### PM2 一键启动
|
||||
|
||||
推荐在 Linux 服务器使用非 root 用户部署:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/ZgDaniel/cc-web.git
|
||||
cd cc-web
|
||||
cp .env.example .env # 可选,不设密码则首次启动自动生成
|
||||
./start.sh
|
||||
```
|
||||
|
||||
脚本默认执行以下动作:
|
||||
|
||||
- 检查 Node.js >= 18 与 npm
|
||||
- 检查 PM2,未安装时自动执行 `npm install -g pm2`
|
||||
- 使用 `npm ci` 安装项目依赖(无 `package-lock.json` 时退回 `npm install`)
|
||||
- 使用 PM2 启动或重启 `server.js`,默认应用名为 `ccweb`
|
||||
- 执行 `pm2 save` 保存当前进程快照
|
||||
|
||||
常用命令:
|
||||
|
||||
```bash
|
||||
pm2 status ccweb
|
||||
pm2 logs ccweb
|
||||
pm2 restart ccweb --update-env
|
||||
```
|
||||
|
||||
如果需要服务器重启后自动恢复 PM2 进程,请执行:
|
||||
|
||||
```bash
|
||||
pm2 startup
|
||||
```
|
||||
|
||||
然后按命令输出的提示执行生成的 `sudo ...` 命令,最后再次执行:
|
||||
|
||||
```bash
|
||||
pm2 save
|
||||
```
|
||||
|
||||
### systemd 服务
|
||||
|
||||
创建 `/etc/systemd/system/cc-web.service`:
|
||||
|
||||
Reference in New Issue
Block a user