1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Ping each SSH connection every 1s during command processing so that long-running commands don't cause the connection to timeout. Add a 0.01s sleep during the command loop so that the CPU doesn't go ballistic while ST is doing its thing.

git-svn-id: http://svn.rubyonrails.org/rails/tools/switchtower@3368 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2006-01-01 04:11:46 +00:00
parent 527a881f95
commit f5ac727c21
2 changed files with 17 additions and 0 deletions

View file

@ -1,5 +1,9 @@
*SVN* *SVN*
* Ping each SSH connection every 1s during command processing so that long-running commands don't cause the connection to timeout.
* Add a 0.01s sleep during the command loop so that the CPU doesn't go ballistic while ST is doing its thing.
* Add :restart_via variable for specifying whether restart ought to use :sudo (default, use sudo) * Add :restart_via variable for specifying whether restart ought to use :sudo (default, use sudo)
* Use SFTP for file transfers (if available). * Use SFTP for file transfers (if available).

View file

@ -24,6 +24,7 @@ module SwitchTower
def process! def process!
logger.debug "processing command" logger.debug "processing command"
since = Time.now
loop do loop do
active = 0 active = 0
@channels.each do |ch| @channels.each do |ch|
@ -33,6 +34,11 @@ module SwitchTower
end end
break if active == 0 break if active == 0
if Time.now - since >= 1
since = Time.now
@channels.each { |ch| ping_connection(ch.connection) }
end
sleep 0.01 # a brief respite, to keep the CPU from going crazy
end end
logger.trace "command finished" logger.trace "command finished"
@ -46,6 +52,13 @@ module SwitchTower
private private
# send an SSH IGNORE packet (this ought to be added to Net::SSH itself,
# so that you could just do connection.ping! instead of the cryptic mess
# below...
def ping_connection(connection)
connection.send_message([2, 4, "ping"].pack("cNA*"))
end
def open_channels def open_channels
@servers.map do |server| @servers.map do |server|
@actor.sessions[server].open_channel do |channel| @actor.sessions[server].open_channel do |channel|