mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-14 00:55:01 +03:00
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:
+5
-2
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user