fix(web): report unexpected HTTP serve failures (#6210)

* fix(web): report unexpected HTTP serve failures

* test(web): cover normal close and all HTTP servers

---------

Co-authored-by: n0ctal <293235942+n0ctal@users.noreply.github.com>
This commit is contained in:
n0ctal
2026-08-14 22:40:53 +05:00
committed by GitHub
parent d291e1c5ee
commit 20b3f84f77
4 changed files with 130 additions and 6 deletions
+17
View File
@@ -0,0 +1,17 @@
package network
import (
"errors"
"net"
"net/http"
"github.com/mhsanaei/3x-ui/v3/internal/logger"
)
// ServeHTTP runs a panel HTTP server and records unexpected listener failures.
// A normal Shutdown returns http.ErrServerClosed and is intentionally silent.
func ServeHTTP(server *http.Server, listener net.Listener, name string) {
if err := server.Serve(listener); err != nil && !errors.Is(err, http.ErrServerClosed) {
logger.Error(name, " stopped unexpectedly: ", err)
}
}