Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bb1e58879 | ||
|
|
62b6cac741 | ||
|
|
2a7dadc2b2 |
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
module Foreman
|
module Foreman
|
||||||
|
|
||||||
VERSION = "0.7.5"
|
VERSION = "0.8.0"
|
||||||
|
|
||||||
class AppDoesNotExist < Exception; end
|
class AppDoesNotExist < Exception; end
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ class Foreman::Engine
|
|||||||
fork process, options
|
fork process, options
|
||||||
end
|
end
|
||||||
|
|
||||||
trap("TERM") { kill_and_exit("TERM") }
|
trap("TERM") { puts "SIGTERM received"; kill_all("TERM") }
|
||||||
trap("INT") { kill_and_exit("INT") }
|
trap("INT") { puts "SIGINT received"; kill_all("INT") }
|
||||||
|
|
||||||
watch_for_termination
|
watch_for_termination
|
||||||
end
|
end
|
||||||
@@ -48,8 +48,8 @@ class Foreman::Engine
|
|||||||
def execute(name, options={})
|
def execute(name, options={})
|
||||||
fork processes[name], options
|
fork processes[name], options
|
||||||
|
|
||||||
trap("TERM") { kill_and_exit("TERM") }
|
trap("TERM") { puts "SIGTERM received"; kill_all("TERM") }
|
||||||
trap("INT") { kill_and_exit("INT") }
|
trap("INT") { puts "SIGINT received"; kill_all("INT") }
|
||||||
|
|
||||||
watch_for_termination
|
watch_for_termination
|
||||||
end
|
end
|
||||||
@@ -97,18 +97,15 @@ private ######################################################################
|
|||||||
rescue PTY::ChildExited, Interrupt
|
rescue PTY::ChildExited, Interrupt
|
||||||
info "process exiting", process
|
info "process exiting", process
|
||||||
end
|
end
|
||||||
Process.waitall
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def kill_and_exit(signal="TERM")
|
def kill_all(signal="TERM")
|
||||||
info "terminating"
|
info "terminating"
|
||||||
running_processes.each do |pid, process|
|
running_processes.each do |pid, process|
|
||||||
info "killing #{process.name} in pid #{pid}"
|
info "killing #{process.name} in pid #{pid}"
|
||||||
Process.kill(signal, pid)
|
Process.kill(signal, pid)
|
||||||
end
|
end
|
||||||
Process.waitall
|
|
||||||
exit 0
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def info(message, process=nil)
|
def info(message, process=nil)
|
||||||
@@ -151,7 +148,8 @@ private ######################################################################
|
|||||||
pid, status = Process.wait2
|
pid, status = Process.wait2
|
||||||
process = running_processes.delete(pid)
|
process = running_processes.delete(pid)
|
||||||
info "process terminated", process
|
info "process terminated", process
|
||||||
kill_and_exit
|
kill_all
|
||||||
|
Process.waitall
|
||||||
end
|
end
|
||||||
|
|
||||||
def running_processes
|
def running_processes
|
||||||
|
|||||||
Reference in New Issue
Block a user