Skip to content

Commit 28ee5eb

Browse files
committed
Fix grpc runtime stop
1 parent e12256e commit 28ee5eb

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# vNext
22

3+
# v1.4.1
4+
5+
- (bug) Fix grpc runtime stop
6+
37
# v1.4.0
48

59
- (feature) Add `OnStopLast` to `Lifecycle`

grpc/grpc.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,20 @@ func New(lifecycle *app.Lifecycle, logger golog.Logger) *grpc.Server {
5555
})
5656

5757
lifecycle.OnStop(func(ctx context.Context) error {
58-
server.GracefulStop()
58+
stopped := make(chan bool)
59+
go func() {
60+
server.GracefulStop()
61+
close(stopped)
62+
}()
63+
64+
t := time.NewTimer(5 * time.Second)
65+
select {
66+
case <-t.C:
67+
server.Stop()
68+
case <-stopped:
69+
t.Stop()
70+
}
71+
5972
return nil
6073
})
6174

0 commit comments

Comments
 (0)