Module: Capistrano::Configuration::Extensions::Connections
- Included in:
- Capistrano::Configuration
- Defined in:
- lib/capistrano/configuration/extensions/connections.rb
Overview
Thread-safeĀ® version of the Capistrano default connection handling.
Instance Method Summary collapse
-
#failed!(server) ⇒ Object
Indicate that the given server could not be connected to.
-
#has_failed?(server) ⇒ Boolean
Query whether previous connection attempts to the given server have failed.
-
#initialize_with_connections(*args) ⇒ Object
:nodoc:.
-
#sessions ⇒ Object
A hash of the SSH sessions that are currently open and available.
- #teardown_connections_to(servers) ⇒ Object
Instance Method Details
#failed!(server) ⇒ Object
Indicate that the given server could not be connected to.
15 16 17 |
# File 'lib/capistrano/configuration/extensions/connections.rb', line 15 def failed!(server) Thread.current[:failed_sessions] << server end |
#has_failed?(server) ⇒ Boolean
Query whether previous connection attempts to the given server have failed.
29 30 31 |
# File 'lib/capistrano/configuration/extensions/connections.rb', line 29 def has_failed?(server) Thread.current[:failed_sessions].include?(server) end |
#initialize_with_connections(*args) ⇒ Object
:nodoc:
8 9 10 11 12 |
# File 'lib/capistrano/configuration/extensions/connections.rb', line 8 def initialize_with_connections(*args) #:nodoc: initialize_without_connections(*args) Thread.current[:sessions] = {} Thread.current[:failed_sessions] = [] end |
#sessions ⇒ Object
A hash of the SSH sessions that are currently open and available. Because sessions are constructed lazily, this will only contain connections to those servers that have been the targets of one or more executed tasks.
23 24 25 |
# File 'lib/capistrano/configuration/extensions/connections.rb', line 23 def sessions Thread.current[:sessions] ||= {} end |
#teardown_connections_to(servers) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/capistrano/configuration/extensions/connections.rb', line 33 def teardown_connections_to(servers) servers.each do |server| sessions[server].close sessions.delete(server) end end |