Class: SSHKit::Runner::Parallel

Inherits:
Abstract
  • Object
show all
Defined in:
lib/sshkit/monkeypatches.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sshkit/monkeypatches.rb', line 20

def execute
  threads = []
  hosts.each do |host|
    threads << Thread.new(host) do |h|
      begin
        backend(h, &block).run
      rescue Exception => e
        e2 = ExecuteError.new e
        raise e2, "Exception while executing #{host.user ? "as #{host.user}@" : "on host "}#{host}:\n#{e.message}\n#{ e.backtrace.join("\n") }"
      end
    end
  end
  threads.map(&:join)
end