Sha256: 78e3efc1a4e8120ccb9bccba67e8f876fa78453b56f37786d11a85ba27087aa1

Contents?: true

Size: 779 Bytes

Versions: 2

Compression:

Stored size: 779 Bytes

Contents

module Micron
  module Util
    module ThreadDump

      # Setup thread dump signal
      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

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
micron-0.5.1 lib/micron/util/thread_dump.rb
micron-0.5.0 lib/micron/util/thread_dump.rb