diff --git a/cmd/context.go b/cmd/context.go deleted file mode 100644 index 867cb3f72..000000000 --- a/cmd/context.go +++ /dev/null @@ -1,20 +0,0 @@ -package cmd - -import ( - "context" - "os" - "os/signal" - "syscall" -) - -// ContextWithSignal creates a context canceled when SIGINT or SIGTERM are notified. -func ContextWithSignal(ctx context.Context) context.Context { - newCtx, cancel := context.WithCancel(ctx) - signals := make(chan os.Signal) - signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM) - go func() { - <-signals - cancel() - }() - return newCtx -} diff --git a/cmd/traefik/traefik.go b/cmd/traefik/traefik.go index 0a772de1e..887b00c95 100644 --- a/cmd/traefik/traefik.go +++ b/cmd/traefik/traefik.go @@ -6,9 +6,11 @@ import ( stdlog "log" "net/http" "os" + "os/signal" "path/filepath" "sort" "strings" + "syscall" "time" "github.com/coreos/go-systemd/daemon" @@ -119,7 +121,7 @@ func runCmd(staticConfiguration *static.Configuration) error { return err } - ctx := cmd.ContextWithSignal(context.Background()) + ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) if staticConfiguration.Experimental != nil && staticConfiguration.Experimental.DevPlugin != nil { var cancel context.CancelFunc