From 4f1a035b31d01ac3e189339cb1ed37186899f357 Mon Sep 17 00:00:00 2001 From: Oliver Morgan Date: Mon, 28 Nov 2022 02:49:06 +0000 Subject: [PATCH] Further Puma 6 fix and fix for #26 (#27) `logger` by default is `events` which doesn't work in Puma 6, it fails with: `undefined method 'log' for #` if `on_stopped` fired before `create_server` --- lib/puma/plugin/yabeda_prometheus.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/puma/plugin/yabeda_prometheus.rb b/lib/puma/plugin/yabeda_prometheus.rb index 87df0cf..737c532 100644 --- a/lib/puma/plugin/yabeda_prometheus.rb +++ b/lib/puma/plugin/yabeda_prometheus.rb @@ -33,7 +33,7 @@ def start(launcher) path = ENV.fetch('PROMETHEUS_EXPORTER_PATH', uri.path) server = nil - logger = events + logger = nil banner = "Yabeda Prometheus metrics exporter on http://#{host}:#{port}#{path}" create_server = -> { @@ -69,7 +69,7 @@ def start(launcher) if events.respond_to?(:on_stopped) && events.respond_to?(:on_restart) events.on_stopped do - unless server&.shutting_down? + if server && !server.shutting_down? logger.log "* Stopping #{banner}" server.stop(true) end