feat: add OperationSetting component and integrate into settings page

- Introduced OperationSetting component for managing agent configurations.
- Updated settings page to include a new tab for operation settings.
- Implemented functionality to fetch and update agent parameters such as heartbeat interval, sync interval, and auto-update settings.

docs: enhance deployment documentation for agent installation

- Added detailed instructions for agent installation using a script.
- Included examples for using discovery and agent tokens.
- Updated sections on global discovery tokens and agent auto-update features.

docs: revise design and development guidelines for V3

- Updated design document to reflect the current state and goals for V3.
- Clarified development guidelines to focus on operational experience improvements.

ci: add GitHub Actions workflow for agent releases

- Created a new workflow to automate the release of agent binaries on GitHub.
- Configured the workflow to build binaries for multiple platforms and publish them as releases.

feat: implement self-update mechanism for agent

- Added updater module to handle checking for and applying updates from GitHub releases.
- Implemented logic to restart the agent after a successful update.

chore: create install script for agent deployment

- Developed a bash script to facilitate the installation of the ATSFlare agent.
- The script supports automatic configuration and systemd service creation.
This commit is contained in:
ryan
2026-03-10 20:22:42 +08:00
parent c568b719b4
commit 83a11ead2b
24 changed files with 1315 additions and 101 deletions
+101 -39
View File
@@ -63,43 +63,43 @@ go run .
### 3.1 节点专属 `agent_token`
```json
{
"server_url": "http://127.0.0.1:3000",
"agent_token": "replace-with-node-auth-token",
"data_dir": "./data",
"nginx_container_name": "atsflare-nginx",
"nginx_docker_image": "nginx:stable-alpine",
"heartbeat_interval": 30000,
"sync_interval": 30000,
"request_timeout": 10000
}
```
```json
{
"server_url": "http://127.0.0.1:3000",
"agent_token": "replace-with-node-auth-token",
"data_dir": "./data",
"nginx_container_name": "atsflare-nginx",
"nginx_docker_image": "nginx:stable-alpine",
"heartbeat_interval": 30000,
"sync_interval": 30000,
"request_timeout": 10000
}
```
### 3.2 全局 `discovery_token`
```json
{
"server_url": "http://127.0.0.1:3000",
"discovery_token": "replace-with-global-discovery-token",
"data_dir": "./data",
"nginx_container_name": "atsflare-nginx",
"nginx_docker_image": "nginx:stable-alpine",
"heartbeat_interval": 30000,
"sync_interval": 30000,
"request_timeout": 10000
}
```
说明:
* `agent_version` 由 Agent 代码内常量提供,升级时同步修改代码
* `nginx_version` 由 Agent 启动时执行命令自动探测
* 时间字段使用毫秒整数
* `agent_token` 与 `discovery_token` 至少填写一个
* 若 `agent_token` 为空且 `discovery_token` 存在,Agent 会自动注册并写回新的专属 `agent_token`
* `node_name` 与 `node_ip` 可省略,未填写时自动探测
* 未配置 `nginx_path` 时,默认使用 Docker Nginx 容器
```json
{
"server_url": "http://127.0.0.1:3000",
"discovery_token": "replace-with-global-discovery-token",
"data_dir": "./data",
"nginx_container_name": "atsflare-nginx",
"nginx_docker_image": "nginx:stable-alpine",
"heartbeat_interval": 30000,
"sync_interval": 30000,
"request_timeout": 10000
}
```
说明:
* `agent_version` 由 Agent 代码内常量提供,升级时同步修改代码
* `nginx_version` 由 Agent 启动时执行命令自动探测
* 时间字段使用毫秒整数
* `agent_token` 与 `discovery_token` 至少填写一个
* 若 `agent_token` 为空且 `discovery_token` 存在,Agent 会自动注册并写回新的专属 `agent_token`
* `node_name` 与 `node_ip` 可省略,未填写时自动探测
* 未配置 `nginx_path` 时,默认使用 Docker Nginx 容器
---
@@ -193,12 +193,74 @@ npm run build
---
## 7. 当前已知限制
## 7. Agent 一键部署(V3)
* 暂未内置 systemd unit 文件
* 暂未提供一键部署脚本
* Docker 模式仍是 MVP 级封装
* 联调以手工步骤为主
### 7.1 curl 安装
在目标机器上运行:
```bash
curl -fsSL https://raw.githubusercontent.com/Rain-kl/ATSFlare/main/scripts/install-agent.sh | bash -s -- \
--server-url http://your-server:3000 \
--discovery-token YOUR_DISCOVERY_TOKEN
```
支持参数:
| 参数 | 说明 | 默认值 |
| ------------------- | -------------------- | --------------------- |
| `--server-url` | Server 地址(必填) | - |
| `--discovery-token` | 全局 Discovery Token | - |
| `--agent-token` | 节点专属 Token | - |
| `--install-dir` | 安装目录 | `/opt/atsflare-agent` |
| `--repo` | GitHub Release 仓库 | `Rain-kl/ATSFlare` |
| `--no-service` | 不创建 systemd 服务 | - |
安装脚本会:
1. 从 GitHub Releases 下载最新 Agent 二进制(`atsflare-agent-{os}-{arch}`)
2. 生成 `agent.json` 配置文件
3. 创建 systemd 服务 `atsflare-agent.service`
4. 启动并启用自启
### 7.2 管理端生成部署命令
在管理端 **系统设置 → 运维设置** 中查看已生成的一键部署命令,直接复制到目标节点执行。
### 7.3 Agent 自动更新
在管理端 **运维设置** 中启用「Agent 自动更新」后,Agent 会在每次心跳周期检查 GitHub Releases,发现新版本时自动下载并重启。
---
## 8. Agent 二进制命名规则
GitHub Release 中的 Agent 二进制命名格式:
* `atsflare-agent-linux-amd64`
* `atsflare-agent-linux-arm64`
* `atsflare-agent-darwin-arm64`
---
## 9. 运维设置热更新(V3)
以下参数可通过管理端 **运维设置** 修改,修改后通过心跳响应下发到 Agent,无需重启:
| 参数 | 说明 | Agent 字段 |
| ---------------------- | -------------------- | ------------------ |
| AgentHeartbeatInterval | 心跳间隔(毫秒) | heartbeat_interval |
| AgentSyncInterval | 同步间隔(毫秒) | sync_interval |
| NodeOfflineThreshold | 节点离线阈值(毫秒) | - |
| AgentAutoUpdate | 是否启用自动更新 | auto_update |
| AgentUpdateRepo | 自动更新仓库 | update_repo |
---
## 10. 当前已知限制
* Docker 模式仍是 MVP 级封装
* 联调以手工步骤为主
---