Skip to content

Commit

Permalink
log loaded extensions when env['PUMA_DEBUG'] is set
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Evans <code@jeremyevans.net>
  • Loading branch information
MSP-Greg and jeremyevans committed Dec 14, 2022
1 parent 7b63010 commit ef174f5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/puma/cluster/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def run

while restart_server.pop
server_thread = server.run

debug_loaded_extensions("Loaded Extensions - worker 0:") if index == 0

stat_thread ||= Thread.new(@worker_write) do |io|
Puma.set_thread_name "stat pld"
base_payload = "p#{Process.pid}"
Expand Down
4 changes: 4 additions & 0 deletions lib/puma/log_writer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ def internal_write(str)
end
private :internal_write

def debug?
@debug
end

def debug(str)
log("% #{str}") if @debug
end
Expand Down
8 changes: 8 additions & 0 deletions lib/puma/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -194,5 +194,13 @@ def stats
}
}
end

def debug_loaded_extensions(str)
if @log_writer.debug?
@log_writer.debug str
re_ext = /\.#{RbConfig::CONFIG['DLEXT']}\z/i
$LOADED_FEATURES.grep(re_ext).each { |f| @log_writer.debug(" #{f}") }
end
end
end
end
2 changes: 2 additions & 0 deletions lib/puma/single.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def run
@server = server = start_server
server_thread = server.run

debug_loaded_extensions("Loaded Extensions:")

log "Use Ctrl-C to stop"
redirect_io

Expand Down

0 comments on commit ef174f5

Please sign in to comment.