Skip to content

Commit

Permalink
Merge pull request #389 from dgrisonnet/signal-handler
Browse files Browse the repository at this point in the history
Add signal handler
  • Loading branch information
k8s-ci-robot authored Mar 29, 2021
2 parents c30c69d + 9db8d2f commit b67ac3e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"os"
"time"

"k8s.io/apimachinery/pkg/util/wait"
openapinamer "k8s.io/apiserver/pkg/endpoints/openapi"
genericapiserver "k8s.io/apiserver/pkg/server"
"k8s.io/client-go/rest"
Expand Down Expand Up @@ -280,8 +279,11 @@ func main() {
klog.Fatalf("unable to load metrics discovery config: %v", err)
}

// stop channel closed on SIGTERM and SIGINT
stopCh := genericapiserver.SetupSignalHandler()

// construct the provider
cmProvider, err := cmd.makeProvider(promClient, wait.NeverStop)
cmProvider, err := cmd.makeProvider(promClient, stopCh)
if err != nil {
klog.Fatalf("unable to construct custom metrics provider: %v", err)
}
Expand All @@ -292,7 +294,7 @@ func main() {
}

// construct the external provider
emProvider, err := cmd.makeExternalProvider(promClient, wait.NeverStop)
emProvider, err := cmd.makeExternalProvider(promClient, stopCh)
if err != nil {
klog.Fatalf("unable to construct external metrics provider: %v", err)
}
Expand All @@ -308,7 +310,7 @@ func main() {
}

// run the server
if err := cmd.Run(wait.NeverStop); err != nil {
if err := cmd.Run(stopCh); err != nil {
klog.Fatalf("unable to run custom metrics adapter: %v", err)
}
}
Expand Down

0 comments on commit b67ac3e

Please sign in to comment.