Class: SSHKit::Runner::Parallel

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

Instance Attribute Summary

Attributes inherited from Abstract

#block, #hosts, #options

Instance Method Summary collapse

Methods inherited from Abstract

#initialize

Constructor Details

This class inherits a constructor from SSHKit::Runner::Abstract

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/sshkit/runners/parallel.rb', line 8

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