Merge pull request #35 from DeBankDeFi/rpc-shutdown-with-timeout

rpc graceful shutdown timeout - merge back from upstream repo
This commit is contained in:
Brion 2022-07-12 01:18:05 +08:00 committed by GitHub
commit c3f82a6595
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -269,8 +269,9 @@ func (h *httpServer) doStop() {
ctx, cancel := context.WithTimeout(context.Background(), shutdownTimeout)
defer cancel()
err := h.server.Shutdown(ctx)
if err != nil {
h.log.Warn("Something wrong with HTTP server graceful shutdown", "error", err)
if 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())