fix(deploy): agent 不再随 server 停 —— 解耦 systemd 依赖(#8 静默掉线根因)
ci-pangolin / Lint — shellcheck (push) Successful in 8s
ci-pangolin / OpenAPI Sync Check (push) Successful in 18s
ci-pangolin / Redline Scan — 脱敏 (UI 文案) (push) Successful in 6s
ci-pangolin / Flutter — analyze + test (push) Failing after 14s
ci-pangolin / Portable SQL — 可移植性 (mysql/sqlite) (push) Successful in 5s
ci-pangolin / Codegen Drift — token 生成物未漂移 (push) Successful in 4s
ci-pangolin / Go — build + test (push) Successful in 10s
ci-pangolin / E2E Smoke — L4 进程级端到端 (push) Successful in 13s
ci-pangolin / Go — integration (mysql/redis testcontainers) (push) Failing after 4m3s
ci-pangolin / Golden — 视觉回归 (components + auth) (push) Successful in 14s

Requires=pangolin-server → Wants=(软依赖);Restart=on-failure → always +
StartLimitIntervalSec=0。根因:Requires= 使每次重启 server 都把 agent 一起拖停
且不自起 → 节点静默 down。agent 本就靠 gRPC 自重连,不该绑 server 生死。
线上 /etc/systemd 已同步 daemon-reload,并重启 server 验证 agent 全程存活+重连。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-06-29 08:22:20 +08:00
parent 3a8e27b5b0
commit ea548ad7cf
@@ -2,14 +2,18 @@
Description=Pangolin node agent (self-enrolls, manages local sing-box)
Documentation=https://github.com/wangjia/pangolin
After=network-online.target pangolin-server.service
Wants=network-online.target
Requires=pangolin-server.service
# 软依赖:server 只是「想要先起」,不绑生死。agent 靠 gRPC 自重连,server 重启
# (如部署)绝不能把 agent 一起拖停——之前 Requires= 正是「agent 静默掉线」根因(#8)。
Wants=network-online.target pangolin-server.service
# 关闭重启频率上限,配合 Restart=always 保证永不放弃自愈(StartLimit* 属 [Unit])。
StartLimitIntervalSec=0
[Service]
Type=simple
EnvironmentFile=/etc/pangolin-agent/agent.env
ExecStart=/usr/local/bin/pangolin-agent
Restart=on-failure
# 始终自愈(崩溃/被依赖停后都拉起);RestartSec 做退避。
Restart=always
RestartSec=5
# The agent calls `systemctl restart sing-box` after rendering config;
# a polkit rule (49-pangolin-singbox.rules) lets the unprivileged pangolin