# MoFin — 部署指南 > 版本: v1.0 | 部署目标: Linux 192.168.1.246 --- ## 部署概览 | 组件 | 守护方式 | 端口 | 说明 | |------|---------|------|------| | **server.py** | systemd `mofin-api` | 8899 | 持仓情报 API(已有,不动) | | **dashboard.py** | systemd `mofin-dashboard` | 8899 | 管理门户(新增) | | **health_check** | crontab `*/5 * * * *` | — | Tier1 健康检查(新增) | --- ## 1. Dashboard 部署 ### 1.1 创建 systemd 服务 ```bash sudo tee /etc/systemd/system/mofin-dashboard.service << 'EOF' [Unit] Description=MoFin Dashboard After=network.target [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 [Install] WantedBy=multi-user.target EOF ``` ### 1.2 启动 ```bash sudo systemctl daemon-reload sudo systemctl enable --now mofin-dashboard sudo systemctl status mofin-dashboard ``` ### 1.3 验证 ```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 ``` --- ## 2. 健康管线部署 ```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 - # 验证 crontab -l | grep health ``` --- ## 3. 防火墙 ```bash sudo ufw status | grep -E '8899|8899' # 如果未开放: # sudo ufw allow 8899/tcp ``` --- ## 4. 部署后验证清单 - [ ] `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` → 无输出(全正常) --- ## 5. 故障恢复 | 问题 | 命令 | |------|------| | Dashboard 挂了 | `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'` |