mirror of
https://gitlab.com/pulsechaincom/go-pulse.git
synced 2025-01-03 01:07:39 +00:00
node: fix HTTP server always force closing (#25755)
Co-authored-by: Felix Lange <fjl@twurst.com>
This commit is contained in:
parent
9d717167aa
commit
25b35c9728
@ -267,13 +267,15 @@ func (h *httpServer) doStop() {
|
|||||||
h.wsHandler.Store((*rpcHandler)(nil))
|
h.wsHandler.Store((*rpcHandler)(nil))
|
||||||
wsHandler.server.Stop()
|
wsHandler.server.Stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
|
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
err := h.server.Shutdown(ctx)
|
err := h.server.Shutdown(ctx)
|
||||||
if err == ctx.Err() {
|
if err != nil && err == ctx.Err() {
|
||||||
h.log.Warn("HTTP server graceful shutdown timed out")
|
h.log.Warn("HTTP server graceful shutdown timed out")
|
||||||
h.server.Close()
|
h.server.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
h.listener.Close()
|
h.listener.Close()
|
||||||
h.log.Info("HTTP server stopped", "endpoint", h.listener.Addr())
|
h.log.Info("HTTP server stopped", "endpoint", h.listener.Addr())
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user