fix: address PR #43 review feedback (M1-M3, S1)
M1: git pull in dev dir + rsync to install dir (install dir has no .git) M2: use asyncio.create_subprocess_exec instead of subprocess.run M3: add repo whitelist (only sanguo/sanguo_moziplus_v2 triggers auto-deploy) S1: notify jiangwei-infra on rsync/pm2 restart failure
This commit is contained in:
@@ -141,15 +141,21 @@ async def _handle_pull_request(payload: Dict[str, Any]) -> None:
|
||||
**触发**:`_handle_pr_closed` 合并事件处理完成后
|
||||
|
||||
**逻辑**:
|
||||
1. `git pull origin main`(安装目录)
|
||||
2. 获取 PR 变更文件列表(复用 `_fetch_pr_files`)
|
||||
3. 判断是否需要重启:文件路径包含 `src/`、`templates/`、`frontend/` 或 `*.py` 后缀 → 重启
|
||||
4. 纯 `docs/` 变更 → 只 pull 不重启
|
||||
5. 部署失败仅 log,不影响 Mail 通知
|
||||
1. 仓库白名单检查(仅 `sanguo/sanguo_moziplus_v2`)
|
||||
2. `git pull origin main`(开发目录 `~/.openclaw/sanguo_projects/sanguo_moziplus_v2/`)
|
||||
3. `rsync` 同步到安装目录(排除 `.git`/`node_modules`/`__pycache__`)
|
||||
4. 获取 PR 变更文件列表(复用 `_fetch_pr_files`)
|
||||
5. 判断是否需要重启:文件路径包含 `src/`、`templates/`、`frontend/` 或 `*.py` 后缀 → 重启
|
||||
6. 纯 `docs/` 变更 → 只 pull + rsync 不重启
|
||||
7. rsync 或 pm2 restart 失败 → 通知 `jiangwei-infra`
|
||||
8. 部署失败仅 log + Mail 通知,不影响合并通知
|
||||
|
||||
**设计决策**:
|
||||
- **git pull 在开发目录**(有 `.git`),rsync 到安装目录:安装目录无 `.git`,直接 git pull 必然失败
|
||||
- **全异步**:所有子进程调用使用 `asyncio.create_subprocess_exec`,不阻塞 event loop
|
||||
- **仓库白名单**:只对 `sanguo/sanguo_moziplus_v2` 触发自动部署,其他仓库忽略
|
||||
- **部署失败通知**:rsync 或 pm2 restart 失败时发 Mail 给 `jiangwei-infra`(S1)
|
||||
- 不做优雅等待(sentinel file 方案):daemon 正在执行任务时重启,已 spawn 的子进程独立运行不受影响,最坏情况是当前 tick 中断、下一轮 PM2 拉起后继续
|
||||
- 部署失败不阻塞通知:Mail 通知和部署解耦,保证信息触达
|
||||
|
||||
### 不做的事
|
||||
|
||||
|
||||
Reference in New Issue
Block a user