Skip to content

Commit

Permalink
Merge branch 'master' into k10-25828-tail-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron-kasten authored Oct 11, 2024
2 parents 243b6c4 + 691adf3 commit 1598fd2
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/kanx/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ func NewServer() *Server {
}

func (s *Server) Serve(ctx context.Context, addr string) error {
stopChan := make(chan os.Signal, 1)
signal.Notify(stopChan, syscall.SIGTERM, syscall.SIGINT)
ctx, can := signal.NotifyContext(ctx, syscall.SIGTERM, syscall.SIGINT)
defer can()
go func() {
select {
case sig := <-stopChan:
log.Info().Print("Gracefully stopping. Received Signal", field.M{"signal": sig})
case <-ctx.Done():
log.Info().Print("Gracefully stopping. Context canceled")
<-ctx.Done()
if err := ctx.Err(); err == context.Canceled {
log.Info().Print("Gracefully stopping. Parent context canceled")
} else {
log.Info().WithError(err).Print("Gracefully stopping.")
}
s.grpcs.GracefulStop()
}()
Expand Down

0 comments on commit 1598fd2

Please sign in to comment.