9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/unicorn/timeout_backtracer.rb', line 9
def kill_worker(signal, wpid)
bin_dir = Gem::Installer.new('gdbruby').bin_dir
gdbruby_bin = "#{bin_dir}/gdbruby.rb"
if ENV['ENABLE_TIMEOUT_LOG'].to_i.nonzero? && FileTest.executable?(gdbruby_bin)
if signal == :KILL
begin
pid = fork do
path = "/tmp/unicorn-timeout-backtrace-#{Process.pid}.log"
log_file = File.open(path, "a")
IO.popen("#{gdbruby_bin} #{wpid}", "r+") do |io|
while line = io.gets
log_file.puts line
end
end
end
Process.waitpid(pid)
rescue => e
p e
end
end
end
unlogged_kill_worker(signal, wpid)
end
|