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

Add a "get" helper, to pull a file from a remote server to the localhost (closes #6978). Also, fix a typo in standard.rb that caused a syntax error.

git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6009 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Jamis Buck 2007-01-22 15:37:35 +00:00
parent 26a6cc7ea2
commit fdd8a65bc8
3 changed files with 31 additions and 1 deletions

View file

@ -1,5 +1,7 @@
*SVN* *SVN*
* Add a "get" helper, to pull a file from a remote server to the localhost [bmihelac]
* Fix gateway to actually increment local_port if a port is in use, so that multiple capistrano instances can run at the same time [Mark Imbriaco] * Fix gateway to actually increment local_port if a port is in use, so that multiple capistrano instances can run at the same time [Mark Imbriaco]
* Refactor the permissions tweaking in update_code to a separate task so that people on shared hosts can override it as necessary [jaw6] * Refactor the permissions tweaking in update_code to a separate task so that people on shared hosts can override it as necessary [jaw6]

View file

@ -261,6 +261,34 @@ module Capistrano
end end
end end
end end
# Get file remote_path from FIRST server targetted by
# the current task and transfer it to local machine as path. It will use
# SFTP if Net::SFTP is installed; otherwise it will fall back to using
# 'cat', which may cause corruption in binary files.
#
# get "#{deploy_to}/current/log/production.log", "log/production.log.web"
def get(remote_path, path, options = {})
if Capistrano::SFTP && options.fetch(:sftp, true)
execute_on_servers(options.merge(:once => true)) do |servers|
logger.debug "downloading #{servers.first}:#{remote_path} to #{path}"
sessions[servers.first].sftp.connect do |tsftp|
tsftp.get_file remote_path, path
end
logger.trace "download finished"
end
else
logger.important "Net::SFTP is not available; using remote 'cat' to get file, which may cause file corruption"
File.open(path, "w") do |destination|
run "cat #{remote_path}", :once => true do |ch, stream, data|
case stream
when :out then destination << data
when :err then raise "error while downloading #{remote_path}: #{data.inspect}"
end
end
end
end
end
# Like #run, but executes the command via <tt>sudo</tt>. This assumes that # Like #run, but executes the command via <tt>sudo</tt>. This assumes that
# the sudo password (if required) is the same as the password for logging # the sudo password (if required) is the same as the password for logging

View file

@ -66,7 +66,7 @@ desc <<-DESC
Sets group permissions on checkout. Useful for team environments, bad on Sets group permissions on checkout. Useful for team environments, bad on
shared hosts. Override this task if you're on a shared host. shared hosts. Override this task if you're on a shared host.
DESC DESC
task :set_permissions task :set_permissions do
run "chmod -R g+w #{release_path}" run "chmod -R g+w #{release_path}"
end end