Skip to content

Commit

Permalink
health: Use signal.NotifyContext
Browse files Browse the repository at this point in the history
This is a cleanup commit with no functional change.

Signed-off-by: Sebastian Wicki <sebastian@isovalent.com>
  • Loading branch information
gandro authored and qmonnet committed Nov 30, 2021
1 parent cfd9da2 commit 6334f98
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions cilium-health/responder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,6 @@ import (
"golang.org/x/sys/unix"
)

func cancelOnSignal(cancel context.CancelFunc, sig ...os.Signal) {
c := make(chan os.Signal, 1)
signal.Notify(c, sig...)
go func() {
<-c
cancel()
}()
}

func main() {
var (
pidfilePath string
Expand All @@ -41,8 +32,7 @@ func main() {
flag.Parse()

// Shutdown gracefully to halt server and remove pidfile
ctx, cancel := context.WithCancel(context.Background())
cancelOnSignal(cancel, unix.SIGINT, unix.SIGHUP, unix.SIGTERM, unix.SIGQUIT)
ctx, cancel := signal.NotifyContext(context.Background(), unix.SIGINT, unix.SIGHUP, unix.SIGTERM, unix.SIGQUIT)

srv := responder.NewServer(listen)
defer srv.Shutdown()
Expand Down

0 comments on commit 6334f98

Please sign in to comment.