Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1680 from captncraig/patch-1
Browse files Browse the repository at this point in the history
Run signal listener in a goroutine instead of deferring.
  • Loading branch information
squaremo authored Feb 13, 2019
2 parents 0824e19 + 6bcfd3d commit b9ec3e7
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions cmd/helm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,6 @@ func main() {
errc <- fmt.Errorf("%s", <-c)
}()

defer func() {
logger.Log("exiting...", <-errc)
close(shutdown)
shutdownWg.Wait()
}()

mainLogger := log.With(logger, "component", "helm-operator")

cfg, err := clientcmd.BuildConfigFromFlags(*master, *kubeconfig)
Expand Down Expand Up @@ -198,9 +192,14 @@ func main() {
go daemonhttp.ListenAndServe(*listenAddr, log.With(logger, "component", "daemonhttp"), shutdown)

// start operator
if err = opr.Run(1, shutdown, shutdownWg); err != nil {
msg := fmt.Sprintf("Failure to run controller: %s", err.Error())
logger.Log("error", msg)
errc <- fmt.Errorf(ErrOperatorFailure, err)
}
go func() {
if err = opr.Run(1, shutdown, shutdownWg); err != nil {
errc <- fmt.Errorf(ErrOperatorFailure, err)
}
}()

shutdownErr := <-errc
logger.Log("exiting...", shutdownErr)
close(shutdown)
shutdownWg.Wait()
}

0 comments on commit b9ec3e7

Please sign in to comment.