diff options
author | 2016-04-29 07:28:35 +0100 | |
---|---|---|
committer | 2016-04-29 07:28:35 +0100 | |
commit | 9e9d72655d865f2d136ad3b0439735cde53b679f (patch) | |
tree | f0c365ffb5fbe9599374ab2551463d610f79ebd6 /core/restart.go | |
parent | a1478f891dd6849835973720df6b5651a8ea88fd (diff) | |
download | coredns-9e9d72655d865f2d136ad3b0439735cde53b679f.tar.gz coredns-9e9d72655d865f2d136ad3b0439735cde53b679f.tar.zst coredns-9e9d72655d865f2d136ad3b0439735cde53b679f.zip |
Make middleware survive a restart (#142)
Make middleware that sets up a (http) handler survive a graceful
restart. We calls the middleware's Shutdown function(s). If restart
fails the Start function is called again.
* middleware/health: OK
* middleware/pprof: OK
* middleware/metrics: OK
All restart OK.
Diffstat (limited to 'core/restart.go')
-rw-r--r-- | core/restart.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/restart.go b/core/restart.go index 1c053c13c..aa77e152d 100644 --- a/core/restart.go +++ b/core/restart.go @@ -117,6 +117,9 @@ func Restart(newCorefile Input) error { } wpipe.Close() + // Run all shutdown functions for the middleware, if child start fails, restart them all... + executeShutdownCallbacks("SIGUSR1") + // Determine whether child startup succeeded answer, readErr := ioutil.ReadAll(sigrpipe) if answer == nil || len(answer) == 0 { @@ -125,6 +128,9 @@ func Restart(newCorefile Input) error { if readErr != nil { log.Printf("[ERROR] Restart: additionally, error communicating with child process: %v", readErr) } + // re-call all startup functions. + // TODO(miek): this needs to be tested, somehow. + executeStartupCallbacks("SIGUSR1") return errIncompleteRestart } |