establish_connections_to (Capistrano::Configuration::Connections)

    # File lib/capistrano/configuration/connections.rb, line 99
          def establish_connections_to(servers)
            failed_servers = []

            # force the connection factory to be instantiated synchronously,
            # otherwise we wind up with multiple gateway instances, because
            # each connection is done in parallel.
            connection_factory

            threads = Array(servers).map { |server| establish_connection_to(server, failed_servers) }
            threads.each { |t| t.join }

            if failed_servers.any?
              errors = failed_servers.map { |h| "#{h[:server]} (#{h[:error].class}: #{h[:error].message})" }
              error = ConnectionError.new("connection failed for: #{errors.join(', ')}")
              error.hosts = failed_servers.map { |h| h[:server] }
              raise error
            end
          end