Grpc graceful shutdown deadline (#1414)

* grpc_graceful_shutdown_deadline

* grpc_graceful_shutdown_deadline
This commit is contained in:
Alex Sharov 2020-12-16 20:14:31 +07:00 committed by GitHub
parent 71ef201c17
commit aebb2d23c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -849,7 +849,16 @@ func (s *Ethereum) Stop() error {
// Stop all the peer-related stuff first.
s.protocolManager.Stop()
if s.privateAPI != nil {
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.