Skip to content

Commit

Permalink
Register signal handers at the very beginning
Browse files Browse the repository at this point in the history
This mitigates the race between process start and any HUP signals
recieved
  • Loading branch information
jacksontj committed Aug 21, 2018
1 parent 425fd24 commit 8a7d3b1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions cmd/promxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ func reloadConfig(rls ...proxyconfig.Reloadable) error {
}

func main() {
// Wait for reload or termination signals. Start the handler for SIGHUP as
// early as possible, but ignore it until we are ready to handle reloading
// our config.
sigs := make(chan os.Signal)
defer close(sigs)
signal.Notify(sigs, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGINT)

prometheus.MustRegister(reloadTime)

Expand Down Expand Up @@ -314,12 +320,7 @@ func main() {
}
}()

// Wait for reload or termination signals. Start the handler for SIGHUP as
// early as possible, but ignore it until we are ready to handle reloading
// our config.
sigs := make(chan os.Signal)
defer close(sigs)
signal.Notify(sigs, syscall.SIGHUP, syscall.SIGTERM, syscall.SIGINT)
// wait for signals etc.
for {
select {
case sig := <-sigs:
Expand Down

0 comments on commit 8a7d3b1

Please sign in to comment.