Skip to content

Commit

Permalink
node: fix HTTP server always force closing (#25755)
Browse files Browse the repository at this point in the history
Co-authored-by: Felix Lange <[email protected]>
  • Loading branch information
ngotchac and fjl authored Sep 14, 2022
1 parent 9d71716 commit 25b35c9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion node/rpcstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,15 @@ func (h *httpServer) doStop() {
h.wsHandler.Store((*rpcHandler)(nil))
wsHandler.server.Stop()
}

ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
defer cancel()
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.server.Close()
}

h.listener.Close()
h.log.Info("HTTP server stopped", "endpoint", h.listener.Addr())

Expand Down

0 comments on commit 25b35c9

Please sign in to comment.