Skip to content

Instantly share code, notes, and snippets.

@ixti
Last active January 2, 2016 10:39
Show Gist options
  • Select an option

  • Save ixti/8291386 to your computer and use it in GitHub Desktop.

Select an option

Save ixti/8291386 to your computer and use it in GitHub Desktop.
--- a/lib/thin/server.rb 2014-01-06 23:53:11.517120396 +0100
+++ b/lib/thin/server.rb 2014-01-06 23:54:18.549990835 +0100
@@ -207,6 +207,17 @@
def running?
@backend.running?
end
+
+ def log_backtrace
+ 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 "<no backtrace available>"
+ end
+ end
+ end
protected
# Register signals:
@@ -215,6 +226,7 @@
def setup_signals
trap('INT') { stop! }
trap('TERM') { stop! }
+ trap('USR2') { log_backtrace }
unless Thin.win?
trap('QUIT') { stop }
trap('HUP') { restart }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment