Skip to content

Commit

Permalink
Further Puma 6 fix and fix for #26 (#27)
Browse files Browse the repository at this point in the history
`logger` by default is `events` which doesn't work in Puma 6, it fails with: `undefined method 'log' for #<Puma::Events:0x00007f905c558720>`  if `on_stopped` fired before `create_server`
  • Loading branch information
ollym authored Nov 28, 2022
1 parent 7513f31 commit 4f1a035
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/puma/plugin/yabeda_prometheus.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = -> {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4f1a035

Please sign in to comment.