From aebb2d23c8536afd6d740f46c32a6b8e49a1d0ed Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Wed, 16 Dec 2020 20:14:31 +0700 Subject: [PATCH] Grpc graceful shutdown deadline (#1414) * grpc_graceful_shutdown_deadline * grpc_graceful_shutdown_deadline --- eth/backend.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/eth/backend.go b/eth/backend.go index af66653fd..54e6bbd8d 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -849,7 +849,16 @@ func (s *Ethereum) Stop() error { // Stop all the peer-related stuff first. s.protocolManager.Stop() if s.privateAPI != nil { - s.privateAPI.GracefulStop() + shutdownDone := make(chan bool) + go func() { + defer close(shutdownDone) + s.privateAPI.GracefulStop() + }() + select { + case <-time.After(1 * time.Second): // shutdown deadline + s.privateAPI.Stop() + case <-shutdownDone: + } } // Then stop everything else.