node: shut down all node-related HTTP servers gracefully (#20956)
Rather than just closing the underlying network listener to stop our HTTP servers, use the graceful shutdown procedure, waiting for any in-process requests to finish.
This commit is contained in:
@ -905,7 +905,7 @@ func retesteth(ctx *cli.Context) error {
|
||||
IdleTimeout: 120 * time.Second,
|
||||
}
|
||||
httpEndpoint := fmt.Sprintf("%s:%d", ctx.GlobalString(utils.RPCListenAddrFlag.Name), ctx.Int(rpcPortFlag.Name))
|
||||
listener, err := node.StartHTTPEndpoint(httpEndpoint, RetestethHTTPTimeouts, handler)
|
||||
httpServer, _, err := node.StartHTTPEndpoint(httpEndpoint, RetestethHTTPTimeouts, handler)
|
||||
if err != nil {
|
||||
utils.Fatalf("Could not start RPC api: %v", err)
|
||||
}
|
||||
@ -913,7 +913,8 @@ func retesteth(ctx *cli.Context) error {
|
||||
log.Info("HTTP endpoint opened", "url", extapiURL)
|
||||
|
||||
defer func() {
|
||||
listener.Close()
|
||||
// Don't bother imposing a timeout here.
|
||||
httpServer.Shutdown(context.Background())
|
||||
log.Info("HTTP endpoint closed", "url", httpEndpoint)
|
||||
}()
|
||||
|
||||
|
Reference in New Issue
Block a user