104 lines
2.9 KiB
Markdown
104 lines
2.9 KiB
Markdown
# MoFin — 部署指南
|
||
|
||
> 版本: v2.0 | 部署目标: Linux 192.168.1.246 | 更新: 2026-08-11
|
||
|
||
---
|
||
|
||
## 部署概览
|
||
|
||
| 组件 | 守护方式 | 端口 | 说明 |
|
||
|------|---------|------|------|
|
||
| **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. 部署流程(正确工作流)
|
||
|
||
> **本地开发 → push Gitea → 246 pull 部署**。不直接在 246 上改代码,否则被 deploy_guard 回滚。
|
||
|
||
```bash
|
||
# 1. 本地开发环境(D:\...\projects\MoFin)提交并推送
|
||
git add . && git commit -m '说明'
|
||
git push origin master # 推送到 Gitea (git.yoin.fun)
|
||
|
||
# 2. 246 部署:从 Gitea 拉取
|
||
ssh hmo@192.168.1.246 "cd ~/MoFin && git pull --rebase"
|
||
|
||
# 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"
|
||
```
|
||
|
||
---
|
||
|
||
## 2. 服务管理
|
||
|
||
```bash
|
||
# 状态/重启(API+Dashboard 一体)
|
||
sudo systemctl status mofin-dashboard
|
||
sudo systemctl restart mofin-dashboard
|
||
|
||
# 日志(journald)
|
||
sudo journalctl -u mofin-dashboard -n 50
|
||
|
||
# 知微/amohe 网关
|
||
sudo systemctl restart hermes-gateway-zhiwei
|
||
sudo systemctl restart hermes-gateway@mohe
|
||
```
|
||
|
||
---
|
||
|
||
## 3. 健康管线
|
||
|
||
```bash
|
||
# 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
|
||
```
|
||
|
||
---
|
||
|
||
## 4. 防火墙
|
||
|
||
```bash
|
||
sudo ufw status | grep 8899
|
||
# 如果未开放:
|
||
# sudo ufw allow 8899/tcp
|
||
```
|
||
|
||
---
|
||
|
||
## 5. 部署后验证清单
|
||
|
||
- [ ] `curl http://127.0.0.1:8899/api/health` → `{"status":"ok"}`
|
||
- [ ] `curl http://127.0.0.1:8899/api/services` → 返回 4 个服务状态
|
||
- [ ] 浏览器打开 `http://192.168.1.246:8899` → Services Tab 显示服务状态
|
||
- [ ] Dashboard F 健康 Tab → 定时任务状态显示正常
|
||
- [ ] `python3 agents_health_check.py` → 无输出(全正常)
|
||
|
||
---
|
||
|
||
## 6. 故障恢复
|
||
|
||
| 问题 | 命令 |
|
||
|------|------|
|
||
| Dashboard/API 挂了 | `ssh hmo@246 'sudo systemctl restart mofin-dashboard'` |
|
||
| 健康检查不运行 | `ssh hmo@246 'crontab -l \| grep health'` |
|
||
| 知微 Gateway 挂了 | `ssh hmo@246 'sudo systemctl restart hermes-gateway-zhiwei'` |
|
||
| deploy_guard 回滚了改动 | 说明改动未提交——先在本地 commit + push,再 246 pull |
|