Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1769847: cmd/gcp-routes-controller: shutdown gcp routes on signal #1317

Merged
merged 1 commit into from
Dec 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions cmd/gcp-routes-controller/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/url"
"os"
"os/exec"
"os/signal"
"sync"
"syscall"
"time"
Expand Down Expand Up @@ -105,6 +106,19 @@ func runRunCmd(cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to start heath checker: %v", err)
}

c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
go func() {
for sig := range c {
glog.Infof("Signal %s received: shutting down gcp routes service", sig)
if err := exec.Command("systemctl", "stop", runOpts.gcpRoutesService).Run(); err != nil {
glog.Infof("Failed to terminate gcp routes service on signal: %s", err)
} else {
break
}
}
}()

for {
select {
case err := <-errCh:
Expand Down