Add timeout switch to CLI

This commit is contained in:
Paulo Luis Franchini Casaretto
2012-10-17 16:05:10 -03:00
parent 8fe86e98c8
commit 61c222deb8
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -23,6 +23,7 @@ class Foreman::CLI < Thor
method_option :env, :type => :string, :aliases => "-e", :desc => "Specify an environment file to load, defaults to .env"
method_option :formation, :type => :string, :aliases => "-m", :banner => '"alpha=5,bar=3"'
method_option :port, :type => :numeric, :aliases => "-p"
method_option :timeout, :type => :numeric, :aliases => "-t", :desc => "Specify the amount of time (in seconds) processes have to shudown gracefully before receiving a SIGKILL, defaults to 5."
class << self
# Hackery. Take the run method away from Thor so that we can redefine it.
+2 -1
View File
@@ -25,6 +25,7 @@ class Foreman::Engine
@options = options.dup
@options[:formation] ||= (options[:concurrency] || "all=1")
@options[:timeout] ||= 5
@env = {}
@mutex = Mutex.new
@@ -305,7 +306,7 @@ private
system "sending SIGTERM to all processes"
killall "SIGTERM"
end
Timeout.timeout(5) do
Timeout.timeout(options[:timeout]) do
watch_for_termination while @running.length > 0
end
rescue Timeout::Error