Module: Micron::Util::ThreadDump
- Included in:
- Micron
- Defined in:
- lib/micron/util/thread_dump.rb
Instance Method Summary collapse
-
#trap_thread_dump ⇒ Object
Setup thread dump signal.
Instance Method Details
#trap_thread_dump ⇒ Object
Setup thread dump signal
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/micron/util/thread_dump.rb', line 7 def trap_thread_dump # print a thread dump on SIGALRM # kill -ALRM <pid> Signal.trap 'SIGALRM' do File.open(File.join(ENV["MICRON_PATH"], "#{$$}.threads.txt"), "w+") do |f| f.puts f.puts "=== micron thread dump: #{Time.now} ===" f.puts Thread.list.each do |thread| f.puts "Thread-#{thread.object_id}" + (thread[:name] ? ": " + thread[:name] : "") f.puts thread.backtrace.join("\n \\_ ") f.puts "-" f.puts end f.puts "=== end micron thread dump ===" f.puts end end end |