docs: 文档治理第二波——更新8份保留文档(QUICKSTART/DEPLOY/DASHBOARD/HEALTH-PIPELINE/portfolio-data-model/morning-health-check/SELF_GROWTH/lifecycle),归档cron-catalog+system-audit

This commit is contained in:
hmo
2026-08-11 04:04:04 +08:00
parent a5a0a46fe9
commit 6929720d47
11 changed files with 111 additions and 84 deletions
+48 -44
View File
@@ -1,6 +1,6 @@
# MoFin — 部署指南
> 版本: v1.0 | 部署目标: Linux 192.168.1.246
> 版本: v2.0 | 部署目标: Linux 192.168.1.246 | 更新: 2026-08-11
---
@@ -8,92 +8,96 @@
| 组件 | 守护方式 | 端口 | 说明 |
|------|---------|------|------|
| **server.py** | systemd `mofin-api` | 8899 | 持仓情报 API(已有,不动) |
| **dashboard.py** | systemd `mofin-dashboard` | 8899 | 管理门户(新增) |
| **health_check** | crontab `*/5 * * * *` | — | Tier1 健康检查(新增) |
| **server.py**API+Dashboard 一体)| systemd `mofin-dashboard` | 8899 | 持仓情报 API + 管理门户(2026-07-19 合并)|
| **hermes gateway**(知微)| systemd `hermes-gateway-zhiwei` | 8643 | 知微 Bot 网关 |
| **hermes gateway**mohe| systemd `hermes-gateway@mohe` | 8646 | mohe Bot 网关 |
| **Tier1 健康检查** | crontab `*/5 * * * *` | — | agents_health_check.py |
> ⚠️ 无独立 `mofin-api` 服务——API 与 Dashboard 合并为 `mofin-dashboard.service`。
---
## 1. Dashboard 部署
## 1. 部署流程(正确工作流)
### 1.1 创建 systemd 服务
> **本地开发 → push Gitea → 246 pull 部署**。不直接在 246 上改代码,否则被 deploy_guard 回滚。
```bash
sudo tee /etc/systemd/system/mofin-dashboard.service << 'EOF'
[Unit]
Description=MoFin Dashboard
After=network.target
# 1. 本地开发环境(D:\...\projects\MoFin)提交并推送
git add . && git commit -m '说明'
git push origin master # 推送到 Gitea (git.yoin.fun)
[Service]
Type=simple
User=hmo
WorkingDirectory=/home/hmo/MoFin
Environment=MOFIN_ROOT=/home/hmo/MoFin
ExecStart=/usr/bin/python3 /home/hmo/MoFin/dashboard.py
Restart=always
RestartSec=10
# 2. 246 部署:从 Gitea 拉取
ssh hmo@192.168.1.246 "cd ~/MoFin && git pull --rebase"
[Install]
WantedBy=multi-user.target
EOF
# 3. 同步脚本硬链接(如有脚本变更)
ssh hmo@192.168.1.246 "cd ~/MoFin && bash deploy/profile-scripts/sync_profile_scripts.sh"
# 4. 重启受影响服务
ssh hmo@192.168.1.246 "sudo systemctl restart mofin-dashboard"
# 5. 验证
ssh hmo@192.168.1.246 "curl -s http://127.0.0.1:8899/api/health"
```
### 1.2 启动
---
## 2. 服务管理
```bash
sudo systemctl daemon-reload
sudo systemctl enable --now mofin-dashboard
# 状态/重启(API+Dashboard 一体)
sudo systemctl status mofin-dashboard
```
sudo systemctl restart mofin-dashboard
### 1.3 验证
# 日志(journald
sudo journalctl -u mofin-dashboard -n 50
```bash
curl http://127.0.0.1:8899/api/health
curl http://127.0.0.1:8899/api/services | python3 -m json.tool
# 浏览器访问: http://192.168.1.246:8899
# 知微/amohe 网关
sudo systemctl restart hermes-gateway-zhiwei
sudo systemctl restart hermes-gateway@mohe
```
---
## 2. 健康管线部署
## 3. 健康管线
```bash
# 添加到 crontab
(crontab -l 2>/dev/null; echo '# MoFin health pipeline'; echo '*/5 * * * * cd /home/hmo/MoFin && /usr/bin/python3 agents_health_check.py >> gateway/logs/health_check_cron.log 2>&1') | crontab -
# 验证
# Tier1 已在 crontab*/5 分钟)
crontab -l | grep health
# 手动运行(无输出 = 全正常)
cd ~/MoFin && python3 agents_health_check.py
# 最近报告
cat ~/MoFin/gateway/temp/last_health_check.json | python3 -m json.tool
```
---
## 3. 防火墙
## 4. 防火墙
```bash
sudo ufw status | grep -E '8899|8899'
sudo ufw status | grep 8899
# 如果未开放:
# sudo ufw allow 8899/tcp
```
---
## 4. 部署后验证清单
## 5. 部署后验证清单
- [ ] `curl http://127.0.0.1:8899/api/health``{"status":"ok"}`
- [ ] `curl http://127.0.0.1:8899/api/services` → 返回 5 个服务状态
- [ ] `curl http://127.0.0.1:8899/api/services` → 返回 4 个服务状态
- [ ] 浏览器打开 `http://192.168.1.246:8899` → Services Tab 显示服务状态
- [ ] Dashboard F 健康 Tab → 定时任务状态显示正常
- [ ] 点击各模块 ?§ 按钮 → 弹出 spec 帮助内容
- [ ] `python3 agents_health_check.py` → 无输出(全正常)
---
## 5. 故障恢复
## 6. 故障恢复
| 问题 | 命令 |
|------|------|
| Dashboard 挂了 | `ssh hmo@246 'sudo systemctl restart mofin-dashboard'` |
| Dashboard/API 挂了 | `ssh hmo@246 'sudo systemctl restart mofin-dashboard'` |
| 健康检查不运行 | `ssh hmo@246 'crontab -l \| grep health'` |
| MoFin API 挂了 | `ssh hmo@246 'sudo systemctl restart mofin-api'` |
| 知微 Gateway 挂了 | `ssh hmo@246 'sudo systemctl restart hermes-gateway@zhiwei'` |
| 知微 Gateway 挂了 | `ssh hmo@246 'sudo systemctl restart hermes-gateway-zhiwei'` |
| deploy_guard 回滚了改动 | 说明改动未提交——先在本地 commit + push,再 246 pull |