node: fix HTTP server always force closing (#25755)

Co-authored-by: Felix Lange <fjl@twurst.com>
pull/25767/head
Nicolas Gotchac 2 years ago committed by GitHub
parent 9d717167aa
commit 25b35c9728
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      node/rpcstack.go

@ -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…
Cancel
Save