fix(web): stop clean shutdowns logging false errors, and let the panel stop its children (#6884)

A systemd stop or restart logged "Server shutdown failed: use of closed
network connection | xray is not running" on every clean exit. httpServer.Shutdown
already closes the listener, so the second Close's net.ErrClosed is now ignored,
and StopXray's not-running case is a sentinel (ErrXrayNotRunning) that Stop
treats as done.

The shipped units now use KillMode=mixed, so SIGTERM reaches only the panel,
which stops Xray and the sidecars itself; systemd still SIGKILLs whatever is left
after the stop timeout.
This commit is contained in:
Rouzbeh†
2026-10-24 06:45:34 +03:30
committed by GitHub
parent 40cea0c2fe
commit ad470681ef
9 changed files with 67 additions and 11 deletions
+5 -2
View File
@@ -787,7 +787,7 @@ func (s *Server) stop(stopXray bool, stopTgBot bool) error {
amneziawgnet.GetOutboundManager().StopAll()
}
if stopXray {
if err := s.xrayService.StopXray(); err != nil {
if err := s.xrayService.StopXray(); err != nil && !errors.Is(err, service.ErrXrayNotRunning) {
err2 = common.Combine(err2, err)
}
}
@@ -811,7 +811,10 @@ func (s *Server) stop(stopXray bool, stopTgBot bool) error {
s.wsHub.Stop()
}
if s.listener != nil {
err1 = common.Combine(err1, s.listener.Close())
// httpServer.Shutdown already closes the listener; ignore closed errors.
if err := s.listener.Close(); err != nil && !errors.Is(err, net.ErrClosed) {
err1 = common.Combine(err1, err)
}
}
return common.Combine(err1, err2)
}