From df710d9efc29d7770782bc7c9557c7b133cfc79d Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sat, 18 Jan 2020 10:18:23 +0000 Subject: [PATCH] hard stop if graceful stop fails after 1 second --- grpc.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/grpc.go b/grpc.go index 1123a67..08c771e 100644 --- a/grpc.go +++ b/grpc.go @@ -810,7 +810,18 @@ func (g *grpcServer) Start() error { } // stop the grpc server - g.srv.Stop() + exit := make(chan bool) + + go func() { + g.srv.GracefulStop() + close(exit) + }() + + select { + case <-exit: + case <-time.After(time.Second): + g.srv.Stop() + } // close transport ch <- nil