DEV: handle termination cleanly in autospec

This commit is contained in:
Sam
2018-06-18 13:20:23 +10:00
parent 91b73e0c2d
commit cc3fc87dd7
4 changed files with 52 additions and 14 deletions

View File

@@ -61,11 +61,14 @@ class Demon::Base
end
end
def stop_signal
"HUP"
end
def stop
@started = false
if @pid
# TODO configurable stop signal
Process.kill("HUP", @pid)
Process.kill(stop_signal, @pid)
wait_for_stop = lambda {
timeout = @stop_timeout
@@ -82,7 +85,7 @@ class Demon::Base
wait_for_stop.call
if alive?
STDERR.puts "Process would not terminate cleanly, force quitting. pid: #{@pid}"
STDERR.puts "Process would not terminate cleanly, force quitting. pid: #{@pid} #{self.class}"
Process.kill("KILL", @pid)
end

View File

@@ -6,6 +6,10 @@ class Demon::RailsAutospec < Demon::Base
"rails-autospec"
end
def stop_signal
"TERM"
end
private
def after_fork