refactor: integrate dashboard into server.py :8899, remove standalone dashboard

This commit is contained in:
hmo
2026-07-19 11:06:50 +08:00
parent 782a914a3c
commit b08bfa5d03
19 changed files with 300 additions and 330 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
# MoFin — Dashboard API 参考
> 版本: v1.0 | 端口: 5807 | 入口: http://192.168.1.246:5807
> 版本: v1.0 | 端口: 8899 | 入口: http://192.168.1.246:8899
---
@@ -94,7 +94,7 @@ MoFin Dashboard
crontab (每 5 分钟)
└── agents_health_check.py → last_health_check.json
Dashboard (:5807)
Dashboard (:8899)
├── /api/services ← 实时 TCP/HTTP 检测
├── /api/monitor ← 聚合读取 health check JSON
└── /api/module-spec/<module> ← 读取 specs/
+9 -9
View File
@@ -9,7 +9,7 @@
| 组件 | 守护方式 | 端口 | 说明 |
|------|---------|------|------|
| **server.py** | systemd `mofin-api` | 8899 | 持仓情报 API(已有,不动) |
| **dashboard.py** | systemd `mofin-dashboard` | 5807 | 管理门户(新增) |
| **dashboard.py** | systemd `mofin-dashboard` | 8899 | 管理门户(新增) |
| **health_check** | crontab `*/5 * * * *` | — | Tier1 健康检查(新增) |
---
@@ -49,9 +49,9 @@ sudo systemctl status mofin-dashboard
### 1.3 验证
```bash
curl http://127.0.0.1:5807/api/health
curl http://127.0.0.1:5807/api/services | python3 -m json.tool
# 浏览器访问: http://192.168.1.246:5807
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
```
---
@@ -71,18 +71,18 @@ crontab -l | grep health
## 3. 防火墙
```bash
sudo ufw status | grep -E '8899|5807'
sudo ufw status | grep -E '8899|8899'
# 如果未开放:
# sudo ufw allow 5807/tcp
# sudo ufw allow 8899/tcp
```
---
## 4. 部署后验证清单
- [ ] `curl http://127.0.0.1:5807/api/health``{"status":"ok"}`
- [ ] `curl http://127.0.0.1:5807/api/services` → 返回 5 个服务状态
- [ ] 浏览器打开 `http://192.168.1.246:5807` → Services Tab 显示服务状态
- [ ] `curl http://127.0.0.1:8899/api/health``{"status":"ok"}`
- [ ] `curl http://127.0.0.1:8899/api/services` → 返回 5 个服务状态
- [ ] 浏览器打开 `http://192.168.1.246:8899` → Services Tab 显示服务状态
- [ ] Dashboard F 健康 Tab → 定时任务状态显示正常
- [ ] 点击各模块 ?§ 按钮 → 弹出 spec 帮助内容
- [ ] `python3 agents_health_check.py` → 无输出(全正常)
+1 -1
View File
@@ -37,7 +37,7 @@
**调度**: `crontab: */5 * * * *`
**检查内容**:
- 5 个服务:MoFin API (:8899) / Dashboard (:5804) / 知微 Gateway (:8643) / ejabberd (:5222) / MoFin DB
- 4 个服务:MoFin API (:8899) / 知微 Gateway (:8643) / ejabberd (:5222) / MoFin DB
- 检查方式:socket 端口 + HTTP /health + SQLite connect
- 全正常时静默(不输出、不写日志)
+4 -4
View File
@@ -1,6 +1,6 @@
# MoFin — 快速操作手册
> 生产环境: Linux 192.168.1.246 | 端口: API 8899 / Dashboard 5807
> 生产环境: Linux 192.168.1.246 | 端口: API 8899 / Dashboard 8899
---
@@ -8,10 +8,10 @@
```bash
# 打开 Dashboard 看全局
http://192.168.1.246:5807
http://192.168.1.246:8899
# 命令行快速状态
ssh hmo@192.168.1.246 "curl -s http://127.0.0.1:5807/api/services | python3 -m json.tool | head -20"
ssh hmo@192.168.1.246 "curl -s http://127.0.0.1:8899/api/services | python3 -m json.tool | head -20"
```
---
@@ -71,7 +71,7 @@ ssh hmo@192.168.1.246 "cd ~/MoFin && git pull --rebase"
ssh hmo@192.168.1.246 "sudo systemctl restart mofin-dashboard"
# 3. 验证
ssh hmo@192.168.1.246 "curl -s http://127.0.0.1:5807/api/health"
ssh hmo@192.168.1.246 "curl -s http://127.0.0.1:8899/api/health"
```
---
@@ -9,7 +9,7 @@ MoFin 项目已运行数月,有 30 个 API 端点、38 个 cron 任务、完
## Decision
参照 AgentsMeeting 样板,为 MoFin 引入:
1. **spec 双轨体系** — 每个模块的 `specs/{module}.json`human_help + ai_spec
2. **Dashboard**独立 `dashboard.py`(端口 5804),深色主题 Web UI + ?§ 按钮
2. **Dashboard**集成到 `server.py`(端口 8899),深色主题 Web UI + ?§ 按钮
3. **健康管线** — Tier15min+ Tier2(日检),聚合到 Dashboard F Tab
4. **开发规范**`docs/dev-spec.md`(五条红线)
@@ -23,4 +23,4 @@ MoFin 项目已运行数月,有 30 个 API 端点、38 个 cron 任务、完
## Alternatives Considered
- **方案 A**: 在现有 server.py 中嵌入 Dashboard(被否 — 改动运行中业务代码风险大)
- **方案 B**: 不做 Dashboard,只补文档(被否 — "不可见即不存在",没有面板等于没做)
- **方案 C**: 独立 dashboard.py(✅ 选择 — 零风险,不影响现有服务
- **方案 C**: 集成到 server.py(✅ 选择 — Dashboard 端点加到现有 Flask 应用,统一端口 8899
+1 -2
View File
@@ -192,8 +192,7 @@ MoFin 已有的编码规范见 `docs/DEVELOPMENT_STANDARDS.md`,包含:
| **生产环境** | Linux 192.168.1.246 |
| **代码目录** | `/home/hmo/MoFin/` |
| **数据库** | `/home/hmo/web-dashboard/data/mofin.db`SQLite |
| **Flask API** | `server.py``:8899` |
| **Dashboard** | `dashboard.py``:5804`(新增) |
| **Flask API** | `server.py``:8899`(含 Dashboard |
| **Python** | 系统 Python 3 |
---