Files
NexusGate/agent-go/INSTALL-GO.md
aaaamoooo f4ef3d96a6
CI / test (push) Canceled after 0s
CI / anytls-smoke (push) Canceled after 0s
chore: migrate self-distribution links from GitHub to self-hosted Gitea
GitHub accounts suspended; all first-party distribution now served from
git.881218.xyz/rogue/NexusGate (Gitea):
- raw:  /rogue/NexusGate/raw/branch/<branch>/<path>
- release assets and source archives under the same repo path
- scripts gain a GIT_BASE variable built from NG_REPO (default
  rogue/NexusGate); NG_REPO/NG_BRANCH/--repo/--branch semantics unchanged
- panel enrollment/uninstall commands in public/app.js point at Gitea raw
- install.sh/nexusgate.sh/agent-singbox.sh stats source previously
  defaulted to the upstream repo (a2899882); defaults now this repo
Upstream dependency references (sagernet/sing-box Go module) untouched.
2026-10-20 11:05:55 +00:00

2.3 KiB
Raw Permalink Blame History

Go Agent 安装/更新流程(自 v0.6.8 起默认)

Agent 已从 Node.js(agent/agent.js)切换为 Go 静态二进制 (agent-go/,约 6MB,实测 RSS 约 12MB,节点机不再需要安装 Node.js)。 协议、环境变量、状态文件格式与 Node 版完全一致(见 PARITY.md), 可直接接管已有节点的状态。

新装(scripts/agent-install.sh)

  • 默认从 Gitea Release 下载二进制: https://git.881218.xyz/rogue/NexusGate/releases/download/agent-v0.6.8/nexusgate-agent-linux-<arch> (<arch> 由 uname -m 决定:x86_64→amd64,aarch64→arm64)
  • 安装到 /opt/nexusgate-agent/nexusgate-agent(0755)。
  • 服务名仍为 nexusgate-agent:
    • systemd:systemd/nexusgate-agent.service,EnvironmentFile=/etc/nexusgate/agent.env, ExecStart=/opt/nexusgate-agent/nexusgate-agent,Restart=always。
    • OpenRC:openrc/nexusgate-agent,command 指向同一二进制, 脚本内手动 source /etc/nexusgate/agent.env(OpenRC 不读 EnvironmentFile)。
  • 其余流程与旧版一致:写 agent.env、注册、安装 sing-box、logrotate、心跳校验。
  • 环境变量:NG_AGENT_RELEASE 可覆盖 Release tag;NG_LOCAL_SRC 指向本地 仓库时从 agent-go/ 取已构建的二进制(离线/调试用)。

更新(scripts/agent-update.sh / ng-agent update)

脚本按已安装程序自动判断实现:

  • 存在 /opt/nexusgate-agent/nexusgate-agent → Go 路径:先用当前二进制 flush-usage 落盘流量计数,再下载同一 Release 资产替换二进制、 刷新服务文件并重启,最后校验心跳。
  • 只有 agent.js → Node 路径:保持旧流程(下载 agent.js/run.sh 并 node --check);刷新服务文件时会把 ExecStart/command 改回经 run.sh 启动。

回退到 Node Agent

  • 新装时回退:NG_AGENT_IMPL=node bash agent-install.sh ...(会安装 nodejs 包、部署 agent/agent.js + agent/run.sh,服务经 run.sh 启动)。
  • 已装 Go 的节点回退:同样用 NG_AGENT_IMPL=node 重跑安装脚本, 它会删除 Go 二进制并部署 Node 版(注册信息会重新生成,需用新 token)。

发布清单(Release: agent-v0.6.8)

需上传到 tag agent-v0.6.8 的资产(文件名必须完全一致):

  • nexusgate-agent-linux-amd64
  • nexusgate-agent-linux-arm64