update tests
This commit is contained in:
@@ -32,8 +32,6 @@ class Foreman::CLI < Thor
|
||||
config = Foreman::Configuration.new(app)
|
||||
error "No such process: #{process}." unless config.processes[process]
|
||||
config.scale(process, amount)
|
||||
rescue Foreman::AppDoesNotExist
|
||||
error "No such app: #{app}."
|
||||
end
|
||||
|
||||
private ######################################################################
|
||||
|
||||
@@ -17,9 +17,9 @@ class Foreman::Configuration
|
||||
amount = amount.to_i
|
||||
|
||||
if (old_amount < amount)
|
||||
((old_amount + 1) .. amount).each { |num| run "start #{app}-#{process} NUM=#{num}" }
|
||||
((old_amount + 1) .. amount).each { |num| system "start #{app}-#{process} NUM=#{num}" }
|
||||
elsif (amount < old_amount)
|
||||
((amount + 1) .. old_amount).each { |num| run "stop #{app}-#{process} NUM=#{num}" }
|
||||
((amount + 1) .. old_amount).each { |num| system "stop #{app}-#{process} NUM=#{num}" }
|
||||
end
|
||||
|
||||
write
|
||||
@@ -27,8 +27,8 @@ class Foreman::Configuration
|
||||
|
||||
def write
|
||||
write_file "/etc/foreman/#{app}.conf", <<-UPSTART_CONFIG
|
||||
#{app}_processes="#{processes.keys.join(' ')}"
|
||||
#{processes.keys.map { |k| "#{app}_#{k}=\"#{processes[k]}\"" }.join("\n")}
|
||||
#{app}_processes="#{processes.keys.sort.join(' ')}"
|
||||
#{processes.keys.sort.map { |k| "#{app}_#{k}=\"#{processes[k]}\"" }.join("\n")}
|
||||
UPSTART_CONFIG
|
||||
end
|
||||
|
||||
@@ -46,10 +46,6 @@ private ######################################################################
|
||||
rescue Errno::ENOENT
|
||||
end
|
||||
|
||||
def run(command)
|
||||
system command
|
||||
end
|
||||
|
||||
def write_file(filename, contents)
|
||||
File.open(filename, "w") do |file|
|
||||
file.puts contents
|
||||
|
||||
+14
-10
@@ -31,12 +31,7 @@ class Foreman::Engine
|
||||
trap("TERM") { kill_and_exit("TERM") }
|
||||
trap("INT") { kill_and_exit("INT") }
|
||||
|
||||
while true
|
||||
pid, status = Process.wait2
|
||||
process = running_processes.delete(pid)
|
||||
info "exited with code #{status}", process
|
||||
fork process
|
||||
end
|
||||
run_loop
|
||||
end
|
||||
|
||||
private ######################################################################
|
||||
@@ -76,16 +71,25 @@ private ######################################################################
|
||||
end
|
||||
end
|
||||
|
||||
def proctitle(title)
|
||||
$0 = title
|
||||
end
|
||||
|
||||
def read_procfile(procfile)
|
||||
File.read(procfile)
|
||||
end
|
||||
|
||||
def run_loop
|
||||
while true
|
||||
pid, status = Process.wait2
|
||||
process = running_processes.delete(pid)
|
||||
info "exited with code #{status}", process
|
||||
fork process
|
||||
end
|
||||
end
|
||||
|
||||
def running_processes
|
||||
@running_processes ||= {}
|
||||
end
|
||||
|
||||
def proctitle(title)
|
||||
$0 = title
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user