public
Description: Remote multi-server automation tool
Homepage: http://www.capify.org
Clone URL: git://github.com/jamis/capistrano.git
Search Repo:
Add synchronous_connect option to force connections to be established 
synchronously, rather than in parallel, in an attempt to work around some 
reported SFTP upload hangs that appear to be related


git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@7201 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
jamis (author)
Sat Jul 21 12:15:58 -0700 2007
commit  af2c2a5ff3162e3c5fb25be904b86036fc4ef4c5
tree    afe66f345d3cd47116ee866dc059800620feb4ab
parent  d7c83a076e6e308856f006f9056d8406bc5161b8
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Added "synchronous_connect" setting to try and work around SFTP hangs for certain users [Jamis Buck]
0
+
0
 * Auto-require the SSH shell service, to avoid race conditions [Jamis Buck]
0
 
0
 * Add a millisecond sleep in upload to reduce CPU impact [Jamis Buck]
...
70
71
72
73
74
75
76
 
 
 
 
 
 
 
 
 
 
 
 
77
78
79
 
 
 
80
81
82
...
136
137
138
139
140
141
142
143
144
145
146
 
 
 
 
 
 
 
 
147
148
149
...
70
71
72
 
 
 
 
73
74
75
76
77
78
79
80
81
82
83
84
85
 
 
86
87
88
89
90
91
...
145
146
147
 
 
 
 
 
 
 
 
148
149
150
151
152
153
154
155
156
157
158
0
@@ -70,13 +70,22 @@ module Capistrano
0
       def establish_connections_to(servers)
0
         failed_servers = []
0
 
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
- connection_factory
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
+ else
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
+ connection_factory
0
 
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
+ end
0
 
0
         if failed_servers.any?
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
- Thread.new do
0
- begin
0
- sessions[server] ||= connection_factory.connect_to(server)
0
- rescue Exception => err
0
- raise unless failures
0
- failures << { :server => server, :error => err }
0
- end
0
- end
0
+ Thread.new { safely_establish_connection_to(server, failures) }
0
+ end
0
+
0
+ def safely_establish_connection_to(server, failures=nil)
0
+ sessions[server] ||= connection_factory.connect_to(server)
0
+ rescue Exception => err
0
+ raise unless failures
0
+ failures << { :server => server, :error => err }
0
         end
0
     end
0
   end

Comments

    No one has commented yet.