mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-08-15 15:50:59 +00:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user