Merge pull request #277 from pcasaretto/add-timeout-switch

Add timeout switch to CLI - fixes #178
This commit is contained in:
David Dollar
2013-01-14 05:12:12 -08:00
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
@@ -312,7 +313,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