fixed tabs
This commit is contained in:
parent
b8cff6023a
commit
aa4b315833
|
@ -165,59 +165,59 @@ module Hydra #:nodoc:
|
||||||
desc "Run #{@name} remotely on all workers"
|
desc "Run #{@name} remotely on all workers"
|
||||||
task "hydra:remote:#{@name}" do
|
task "hydra:remote:#{@name}" do
|
||||||
config = YAML.load_file(@config)
|
config = YAML.load_file(@config)
|
||||||
environment = config.fetch('environment') { 'test' }
|
environment = config.fetch('environment') { 'test' }
|
||||||
workers = config.fetch('workers') { [] }
|
workers = config.fetch('workers') { [] }
|
||||||
workers = workers.select{|w| w['type'] == 'ssh'}
|
workers = workers.select{|w| w['type'] == 'ssh'}
|
||||||
|
|
||||||
$stdout.write "==== Hydra Running #{@name} ====\n"
|
$stdout.write "==== Hydra Running #{@name} ====\n"
|
||||||
Thread.abort_on_exception = true
|
Thread.abort_on_exception = true
|
||||||
@listeners = []
|
@listeners = []
|
||||||
@results = {}
|
@results = {}
|
||||||
workers.each do |worker|
|
workers.each do |worker|
|
||||||
@listeners << Thread.new do
|
@listeners << Thread.new do
|
||||||
begin
|
begin
|
||||||
@results[worker] = if run_task(worker, environment)
|
@results[worker] = if run_task(worker, environment)
|
||||||
"==== #{@name} passed on #{worker['connect']} ====\n"
|
"==== #{@name} passed on #{worker['connect']} ====\n"
|
||||||
else
|
else
|
||||||
"==== #{@name} failed on #{worker['connect']} ====\nPlease see above for more details.\n"
|
"==== #{@name} failed on #{worker['connect']} ====\nPlease see above for more details.\n"
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
@results[worker] = "==== #{@name} failed for #{worker['connect']} ====\n#{$!.inspect}\n#{$!.backtrace.join("\n")}"
|
@results[worker] = "==== #{@name} failed for #{worker['connect']} ====\n#{$!.inspect}\n#{$!.backtrace.join("\n")}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@listeners.each{|l| l.join}
|
@listeners.each{|l| l.join}
|
||||||
$stdout.write "\n==== Hydra Running #{@name} COMPLETE ====\n\n"
|
$stdout.write "\n==== Hydra Running #{@name} COMPLETE ====\n\n"
|
||||||
$stdout.write @results.values.join('\n')
|
$stdout.write @results.values.join('\n')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_task worker, environment
|
def run_task worker, environment
|
||||||
$stdout.write "==== Hydra Running #{@name} on #{worker['connect']} ====\n"
|
$stdout.write "==== Hydra Running #{@name} on #{worker['connect']} ====\n"
|
||||||
ssh_opts = worker.fetch('ssh_opts') { '' }
|
ssh_opts = worker.fetch('ssh_opts') { '' }
|
||||||
writer, reader, error = popen3("ssh -tt #{ssh_opts} #{worker['connect']} ")
|
writer, reader, error = popen3("ssh -tt #{ssh_opts} #{worker['connect']} ")
|
||||||
writer.write("cd #{worker['directory']}\n")
|
writer.write("cd #{worker['directory']}\n")
|
||||||
writer.write "echo BEGIN HYDRA\n"
|
writer.write "echo BEGIN HYDRA\n"
|
||||||
writer.write("RAILS_ENV=#{environment} rake #{@name}\n")
|
writer.write("RAILS_ENV=#{environment} rake #{@name}\n")
|
||||||
writer.write "echo END HYDRA\n"
|
writer.write "echo END HYDRA\n"
|
||||||
writer.write("exit\n")
|
writer.write("exit\n")
|
||||||
writer.close
|
writer.close
|
||||||
ignoring = true
|
ignoring = true
|
||||||
passed = true
|
passed = true
|
||||||
while line = reader.gets
|
while line = reader.gets
|
||||||
line.chomp!
|
line.chomp!
|
||||||
if line =~ /^rake aborted!$/
|
if line =~ /^rake aborted!$/
|
||||||
passed = false
|
passed = false
|
||||||
end
|
end
|
||||||
if line =~ /echo END HYDRA$/
|
if line =~ /echo END HYDRA$/
|
||||||
ignoring = true
|
ignoring = true
|
||||||
end
|
end
|
||||||
$stdout.write "#{worker['connect']}: #{line}\n" unless ignoring
|
$stdout.write "#{worker['connect']}: #{line}\n" unless ignoring
|
||||||
if line == 'BEGIN HYDRA'
|
if line == 'BEGIN HYDRA'
|
||||||
ignoring = false
|
ignoring = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
passed
|
passed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue