middleware/metrics: survive restart (#542)

* middleware/metrics: survive restart

Keep the handler running during restart. Stopping and starting the
handler results in "address in use" - sometimes, meaning the reload
will be flaky. In turn this behavior means any changes to the monitor
stanza are not picked up.

* remove resync
This commit is contained in:
Miek Gieben
2017-02-21 19:34:40 +00:00
committed by GitHub
parent 26242cef1b
commit 7c59d39834
3 changed files with 33 additions and 29 deletions

View File

@@ -28,9 +28,10 @@ func setup(c *caddy.Controller) error {
return m
})
// During restarts we will keep this handler running.
metricsOnce.Do(func() {
c.OnStartup(m.OnStartup)
c.OnShutdown(m.OnShutdown)
c.OncePerServerBlock(m.OnStartup)
c.OnFinalShutdown(m.OnShutdown)
})
return nil