cmd/gcp-routes-controller: shutdown gcp routes on signal
Closes: BZ
@@ -8,6 +8,7 @@ import (
"net/url"
"os"
"os/exec"
+ "os/signal"
"sync"
"syscall"
"time"
@@ -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:
