docs: CLAUDE.md 新增部署流程 + Health 纯文本修复

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Your Name
2026-05-30 02:30:49 +08:00
parent f7c4b95dd6
commit e709c72f1f
+50
View File
@@ -116,6 +116,9 @@ Nexus/
| P2-7 凭据加密 | server/api/servers.py | Server.password/ssh_key_private Fernet加密存储 |
| P2-8 凭据脱敏 | server/api/scripts.py + servers.py | API响应不返回密码,password_set布尔标记 |
| P2-9 DB备份 | deploy/db_backup.sh | mysqldump+30天保留+cron集成 |
| **P3运维增强** | | |
| P3-1 Nginx重定向 | deploy/nginx_https.conf | 注释化301规则:裸页面路径→/app/前缀 |
| P3-2 自定义404 | server/main.py | StarletteHTTPExceptionHandler返回空白HTML,隐藏FastAPI标识 |
### 🔄 待测试
- T1: 心跳Redis写入验证
@@ -198,6 +201,53 @@ MCP gate_log 工具可查看历史门控记录
Lint配置: `ruff.toml`
开发依赖: `requirements-dev.txt`ruff, bandit, pytest
## 部署流程(SSH + SCP,不是 MCP deploy
**MCP deploy 不可用**GitHub 等 SaaS 的远程服务器 git pull 无凭据),实际部署用 SSH 命令直接操作:
```bash
# 0. 准备:服务器已配置 Gitea Token(一次性)
ssh nexus "cd /www/wwwroot/api.synaglobal.vip && git remote set-url origin http://admin:TOKEN@66.154.115.8:3000/admin/Nexus.git"
# TOKEN: Gitea 用户设置 → 应用 → 生成令牌 (nexus-deploy-token, 26fee743...)
# 1. Push 本地到 Gitea
git push origin main
# 2. 服务器拉取最新代码
ssh nexus "cd /www/wwwroot/api.synaglobal.vip && git fetch --all && git reset --hard origin/main"
# 3. 增量修复(如有 bandit/lint 问题已 fix 但未 push
scp server/api/file.py nexus:/www/wwwroot/api.synaglobal.vip/server/api/file.py
# 4. 重启服务
ssh nexus "cd /www/wwwroot/api.synaglobal.vip && supervisorctl restart nexus"
# 5. 健康检查
ssh nexus "sleep 2 && curl -s http://127.0.0.1:8600/health"
# 预期: "ok"(纯文本,非 JSON
# 6. 浏览器验证
# Playwright 打开 https://api.synaglobal.vip/app/index.html
```
### 部署常遇问题
| 问题 | 解决 |
|------|------|
| MCP deploy → git pull 失败 `could not read Username` | 服务器 remote URL 没配 token,用上面的 `git remote set-url` |
| Gate 2 Audit BLOCKED | 创建 `docs/audit/YYYY-MM-DD-topic.md`,含 Step3+Closure+DoD |
| Gate 3 Test BLOCKED (401) | 服务器 .env 中 `NEXUS_TEST_ADMIN_PASSWORD` 与数据库不一致 |
| Gate 6 Security BLOCKED (bandit HIGH) | md5 → sha256 等,参看 bandit 报告修复 |
| Gate 7 Review BLOCKED | 审计文件缺少实际改动文件清单 |
### 部署信息速查
- **部署用户**: root
- **部署目录**: `/www/wwwroot/api.synaglobal.vip/`
- **Supervisor 服务名**: `nexus`
- **Supervisor 配置**: `/www/server/panel/plugin/supervisor/etc/supervisor.conf`
- **SSH 别名**: `ssh nexus` (47.254.123.106, key: id_rsa_nexus)
- **后端端口**: 8600
- **Gitea Token SHA**: `26fee743a9332895b55f79b2dbe2e931dc7c2fe5` (nexus-deploy-token, write:repository)
**用户审查清单(验证AI是否偷懒):**
1.`deploy/gate_log.jsonl` — 每次门控都有记录,没有记录 = 没过门控
2. 看审计文件 — 必须有 Closure 表(每个H的判定+依据)、Step 3 规则扫描、DoD