feat(agent): SIGHUP 重读节点本地配置并热重渲染,不踢在线用户

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
wangjia
2026-07-23 02:15:27 +08:00
parent d216e157c3
commit 6f183ff0df
3 changed files with 50 additions and 0 deletions
+17
View File
@@ -44,6 +44,23 @@ func main() {
ctx, stop := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
defer stop()
// SIGHUP 重读节点本地配置(acl.json / warp.json)并重渲染。走 sing-box 的 SIGHUP
// 热重载路径,在线用户不掉线;重启 agent 则会冷启 sing-box,把所有人踢下线。
hup := make(chan os.Signal, 1)
signal.Notify(hup, syscall.SIGHUP)
defer signal.Stop(hup)
go func() {
for {
select {
case <-ctx.Done():
return
case <-hup:
log.Printf("[pangolin-agent] SIGHUP: re-reading node-local config (acl.json/warp.json)")
agent.SingBox().Refresh()
}
}
}()
log.Printf("[pangolin-agent] starting (control-plane=%s, version=%s)", cfg.ControlPlaneAddr, cfg.AgentVersion)
start := time.Now()
if err := agent.Run(ctx); err != nil {