Files
Nexus/docs/changelog/2026-05-27-agent-install-fix-and-deploy.md
T
2026-07-08 22:31:31 +08:00

58 lines
2.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 2026-05-27 Agent安装修复 + 两台子服务器Agent部署
## 变更摘要
1. 修复 Agent 安装 404 错误(/agent/ 静态文件未挂载)
2. 修复 curl|bash 管道错误隐藏问题
3. 修复 CRLF 导致远程 shell 脚本执行失败
4. 部署 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→LF
- `web/agent/agent.py` — CRLF→LF
- `web/agent/agent.sh` — CRLF→LF
### 部署脚本
- `deploy/install.sh` — CRLF→LF
- `deploy/health_monitor.sh` — CRLF→LF
- `deploy/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`
- 否:无数据库迁移
## 验证方式
1. `curl https://api.synaglobal.vip/agent/install.sh` → 返回脚本内容(非 404
2. Nexus Dashboard 显示 2 台服务器在线
3. `curl https://api.synaglobal.vip/api/servers/8``is_online: true, agent_version: "2.0.0"`
4. `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 但无具体错误信息,需改进错误上报