Skip to content

Instantly share code, notes, and snippets.

@kirs
Last active August 6, 2016 16:50
Show Gist options
  • Save kirs/712db4a6c0f338c18f7257b1d37068b4 to your computer and use it in GitHub Desktop.
Save kirs/712db4a6c0f338c18f7257b1d37068b4 to your computer and use it in GitHub Desktop.
Debug stuck unicorn threads
after_fork do |server, worker|
Signal.trap('USR2') do
pid = Process.pid
puts "[#{pid}] Received USR2 at #{Time.now}. Dumping threads:"
Thread.list.each do |t|
trace = t.backtrace.join("\n[#{pid}] ")
puts "[#{pid}] #{trace}"
puts "[#{pid}] ---"
end
puts "[#{pid}] -------------------"
end
end
@kirs
Copy link
Author

kirs commented Aug 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment