2.3 KiB
2.3 KiB
2026-05-27 Agent安装修复 + 两台子服务器Agent部署
变更摘要
- 修复 Agent 安装 404 错误(/agent/ 静态文件未挂载)
- 修复 curl|bash 管道错误隐藏问题
- 修复 CRLF 导致远程 shell 脚本执行失败
- 部署 Agent 到两台子服务器
动机
Agent 安装命令一直返回 404,因为 FastAPI 未挂载 /agent/ 静态文件路由。
curl|bash 管道模式会隐藏下载失败。
Windows 工作区给 .sh/.py 文件添加了 CRLF,导致 Linux 上 \r': command not found。
涉及文件
后端
server/main.py— 新增app.mount("/agent", StaticFiles(...))挂载 web/agent/ 目录server/api/servers.py— 3处curl ... | bash -s --改为TMP=$(mktemp) && curl ... -o "$TMP" && bash "$TMP" --
前端/Agent
web/agent/install.sh— CRLF→LFweb/agent/agent.py— CRLF→LFweb/agent/agent.sh— CRLF→LF
部署脚本
deploy/install.sh— CRLF→LFdeploy/health_monitor.sh— CRLF→LFdeploy/db_backup.sh— CRLF→LF
根目录
.gitattributes— 新增,防止 git 自动转 CRLF(*.sh eol=lf, *.py eol=lf)
Agent 部署结果
| 服务器 | IP | server_id | 状态 |
|---|---|---|---|
| 机器人 | 66.154.115.131 | 8 | ✅ online, agent_version=2.0.0 |
| 冲量银海 | 39.105.228.140 | 9 | ✅ online, agent_version=2.0.0 |
冲量银海额外步骤
- 需先
apt install python3.11-venv(Debian 12 默认不带 python3.11-venv) - install.sh 第2步
python3 -m venv在缺少 ensurepip 时会静默失败,source activate 报错
需要迁移/重启
- 是:需重启 Nexus 后端(Supervisor:
supervisorctl restart nexus) - 是:需 Nginx reload(
nginx -s reload) - 否:无数据库迁移
验证方式
curl https://api.synaglobal.vip/agent/install.sh→ 返回脚本内容(非 404)- Nexus Dashboard 显示 2 台服务器在线
curl https://api.synaglobal.vip/api/servers/8→is_online: true, agent_version: "2.0.0"curl https://api.synaglobal.vip/api/servers/9→is_online: true, agent_version: "2.0.0"
已知问题
- install.sh 第2步 venv 创建在缺少 python3-venv 时会静默失败,应加检测
- batch install API 返回 success:false 但无具体错误信息,需改进错误上报