correct regression where monitoring thread crashed out
add logging
This commit is contained in:
parent
771eeea837
commit
0e4883a8ae
|
@ -50,9 +50,10 @@ class Demon::Base
|
||||||
"#{Rails.root}/tmp/pids/#{self.class.prefix}_#{@index}.pid"
|
"#{Rails.root}/tmp/pids/#{self.class.prefix}_#{@index}.pid"
|
||||||
end
|
end
|
||||||
|
|
||||||
def alive?
|
def alive?(pid=nil)
|
||||||
if @pid
|
pid ||= @pid
|
||||||
Demon::Base.alive?(@pid)
|
if pid
|
||||||
|
Demon::Base.alive?(pid)
|
||||||
else
|
else
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
@ -145,12 +146,10 @@ class Demon::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.alive?(pid)
|
def self.alive?(pid)
|
||||||
begin
|
Process.kill(0, pid)
|
||||||
Process.kill(0, pid)
|
true
|
||||||
true
|
rescue
|
||||||
rescue
|
false
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
@ -169,10 +168,14 @@ class Demon::Base
|
||||||
def monitor_parent
|
def monitor_parent
|
||||||
Thread.new do
|
Thread.new do
|
||||||
while true
|
while true
|
||||||
unless alive?(@parent_pid)
|
begin
|
||||||
Process.kill "TERM", Process.pid
|
unless alive?(@parent_pid)
|
||||||
sleep 10
|
Process.kill "TERM", Process.pid
|
||||||
Process.kill "KILL", Process.pid
|
sleep 10
|
||||||
|
Process.kill "KILL", Process.pid
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
STDERR.puts "URGENT monitoring thread had an exception #{e}"
|
||||||
end
|
end
|
||||||
sleep 1
|
sleep 1
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue