Skip to content

Commit

Permalink
Add missed cancel branch
Browse files Browse the repository at this point in the history
Signed-off-by: Kemal Akkoyun <kakkoyun@gmail.com>
  • Loading branch information
kakkoyun committed Oct 28, 2019
1 parent 1e8614c commit 3927f73
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/server/grpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,16 @@ func (s *GRPCServer) ListenAndServe() error {
}

func (s *GRPCServer) Shutdown(err error) {
ctx, cancel := context.WithTimeout(context.Background(), s.opts.gracePeriod)

stopped := make(chan struct{})
go func() {
level.Info(s.logger).Log("msg", "gracefully stoping server")
s.srv.GracefulStop() // Also closes s.listener.
close(stopped)
}()

ctx, cancel := context.WithTimeout(context.Background(), s.opts.gracePeriod)
defer cancel()

select {
case <-ctx.Done():
level.Info(s.logger).Log("msg", "timeout, grace period exceeded")
Expand Down

0 comments on commit 3927f73

Please sign in to comment.