Remove ALL_PROCESSES and default the name arguments to #start/#stop to nil

This commit is contained in:
R. Tyler Croy committed 2012-04-11 10:25:58 -07:00
1 parent b2bf95479e
commit 3a2a53be95
1 file changed
+6 -9
+6 -9
View File
@@ -15,9 +15,6 @@ class Foreman::Engine
attr_reader :directory attr_reader :directory
attr_reader :options attr_reader :options
# This constant is here to make the invocations of #start and #stop methods
# clearer
ALL_PROCESSES = nil
COLORS = %w( cyan yellow green magenta red blue intense_cyan intense_yellow COLORS = %w( cyan yellow green magenta red blue intense_cyan intense_yellow
intense_green intense_magenta intense_red, intense_blue ) intense_green intense_magenta intense_red, intense_blue )
@@ -39,17 +36,17 @@ class Foreman::Engine
trap("INT") { puts "SIGINT received"; terminate_gracefully } trap("INT") { puts "SIGINT received"; terminate_gracefully }
assign_colors assign_colors
start ALL_PROCESSES start
watch_for_output watch_for_output
watch_for_termination watch_for_termination
terminate_gracefully terminate_gracefully
end end
def start(name) def start(name=nil)
concurrency = Foreman::Utils.parse_concurrency(@options[:concurrency]) concurrency = Foreman::Utils.parse_concurrency(@options[:concurrency])
procfile.entries.each do |entry| procfile.entries.each do |entry|
unless name == ALL_PROCESSES unless name == nil
next unless entry.name == name next unless entry.name == name
end end
@@ -61,7 +58,7 @@ class Foreman::Engine
end end
end end
def stop(name, signal='SIGTERM') def stop(name=nil, signal='SIGTERM')
running_processes.each do |pid, process| running_processes.each do |pid, process|
unless name == ALL_PROCESSES unless name == ALL_PROCESSES
# Comparing against process.entry.name instead of process.name to # Comparing against process.entry.name instead of process.name to
@@ -104,10 +101,10 @@ private ######################################################################
return if @terminating return if @terminating
@terminating = true @terminating = true
Timeout.timeout(5) do Timeout.timeout(5) do
stop ALL_PROCESSES stop
end end
rescue Timeout::Error rescue Timeout::Error
stop(ALL_PROCESSES, 'SIGKILL') stop(nil, 'SIGKILL')
rescue Errno::ECHILD rescue Errno::ECHILD
end end