aboutsummaryrefslogtreecommitdiff
path: root/plugin/metrics/metrics.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/metrics/metrics.go')
-rw-r--r--plugin/metrics/metrics.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/plugin/metrics/metrics.go b/plugin/metrics/metrics.go
index 0c24ffd15..a49984b3d 100644
--- a/plugin/metrics/metrics.go
+++ b/plugin/metrics/metrics.go
@@ -104,7 +104,14 @@ func (m *Metrics) OnStartup() error {
}
// OnShutdown tears down the metrics listener on shutdown and restart.
-func (m *Metrics) OnShutdown() error { return m.ln.Close() }
+func (m *Metrics) OnShutdown() error {
+ // We allow prometheus statements in multiple Server Blocks, but only the first
+ // will open the listener, for the rest they are all nil; guard against that.
+ if m.ln != nil {
+ return m.ln.Close()
+ }
+ return nil
+}
func keys(m map[string]bool) []string {
sx := []string{}