diff --git a/lib/puma/cluster.rb b/lib/puma/cluster.rb index 44cb8b4bd5..029a93510d 100644 --- a/lib/puma/cluster.rb +++ b/lib/puma/cluster.rb @@ -111,6 +111,17 @@ def hup Process.kill "HUP", @pid rescue Errno::ESRCH end + + def info + Thread.list.each do |thread| + log "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}" + if thread.backtrace + log thread.backtrace.join("\n") + else + log "" + end + end + end end def spawn_workers @@ -264,6 +275,10 @@ def worker(index, master) server.stop end + Signal.trap "SIGINFO" do + server.log_thread_status + end + begin @worker_write << "b#{Process.pid}\n" rescue SystemCallError, IOError diff --git a/lib/puma/server.rb b/lib/puma/server.rb index 97efa85735..e771eb35b3 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -954,5 +954,16 @@ def self.current def shutting_down? @status == :stop || @status == :restart end + + def log_thread_status + Thread.list.each do |thread| + @events.log "Thread TID-#{thread.object_id.to_s(36)} #{thread['label']}" + if thread.backtrace + @events.log thread.backtrace.join("\n") + else + @events.log "" + end + end + end end end diff --git a/lib/puma/single.rb b/lib/puma/single.rb index 4adf56ea87..cf8fcd4444 100644 --- a/lib/puma/single.rb +++ b/lib/puma/single.rb @@ -102,6 +102,10 @@ def run @launcher.events.fire_on_booted! + Signal.trap "SIGINFO" do + server.log_thread_status + end + begin server.run.join rescue Interrupt