0
@@ -70,13 +70,22 @@ module Capistrano
0
def establish_connections_to(servers)
0
- # force the connection factory to be instantiated synchronously,
0
- # otherwise we wind up with multiple gateway instances, because
0
- # each connection is done in parallel.
0
+ # This attemps to work around the problem where SFTP uploads hang
0
+ # for some people. A bit of investigating seemed to reveal that the
0
+ # hang only occurred when the SSH connections were established async,
0
+ # so this setting allows people to at least work around the problem.
0
+ if fetch(:synchronous_connect, false)
0
+ logger.trace "synchronous_connect: true"
0
+ Array(servers).each { |server| safely_establish_connection_to(server, failed_servers) }
0
+ # force the connection factory to be instantiated synchronously,
0
+ # otherwise we wind up with multiple gateway instances, because
0
+ # each connection is done in parallel.
0
- threads = Array(servers).map { |server| establish_connection_to(server, failed_servers) }
0
- threads.each { |t| t.join }
0
+ threads = Array(servers).map { |server| establish_connection_to(server, failed_servers) }
0
+ threads.each { |t| t.join }
0
errors = failed_servers.map { |h| "#{h[:server]} (#{h[:error].class}: #{h[:error].message})" }
0
@@ -136,14 +145,14 @@ module Capistrano
0
# prevents problems with the thread's scope seeing the wrong 'server'
0
# variable if the thread just happens to take too long to start up.
0
def establish_connection_to(server, failures=nil)
0
- sessions[server] ||= connection_factory.connect_to(server)
0
- rescue Exception => err
0
- failures << { :server => server, :error => err }
0
+ Thread.new { safely_establish_connection_to(server, failures) }
0
+ def safely_establish_connection_to(server, failures=nil)
0
+ sessions[server] ||= connection_factory.connect_to(server)
0
+ rescue Exception => err
0
+ failures << { :server => server, :error => err }
Comments
No one has commented yet.