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

Run signal listener in a goroutine instead of deferring. #1680

Merged
merged 2 commits into from
Feb 13, 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
21 changes: 10 additions & 11 deletions cmd/helm-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,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 @@ -195,9 +189,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()
}