Class: Capistrano::Deploy::Strategy::Copy
- Defined in:
- lib/capistrano/recipes/deploy/strategy/copy.rb
Overview
This class implements the strategy for deployments which work by preparing the source code locally, compressing it, copying the file to each target host, and uncompressing it to the deployment directory.
By default, the SCM checkout command is used to obtain the local copy of the source code. If you would rather use the export operation, you can set the :copy_strategy variable to :export.
This deployment strategy supports a special variable, :copy_compression, which must be one of :gzip, :bz2, or :zip, and which specifies how the source should be compressed for transmission to each host.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #check! ⇒ Object
-
#deploy! ⇒ Object
Obtains a copy of the source code locally (via the #command method), compresses it to a single file, copies that file to all target servers, and uncompresses it on each of them into the deployment directory.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Capistrano::Deploy::Strategy::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Capistrano::Deploy::Strategy::Base
Instance Method Details
#check! ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/capistrano/recipes/deploy/strategy/copy.rb', line 43 def check! super.check do |d| d.local.command(source.local.command) d.local.command(compress(nil, nil).first) d.remote.command(decompress(nil).first) end end |
#deploy! ⇒ Object
Obtains a copy of the source code locally (via the #command method), compresses it to a single file, copies that file to all target servers, and uncompresses it on each of them into the deployment directory.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/capistrano/recipes/deploy/strategy/copy.rb', line 27 def deploy! logger.debug "getting (via #{copy_strategy}) revision #{revision} to #{destination}" system(command) File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) } logger.trace "compressing #{destination} to #{filename}" Dir.chdir(tmpdir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) } content = File.open(filename, "rb") { |f| f.read } put content, remote_filename run "cd #{configuration[:releases_path]} && #{decompress(remote_filename).join(" ")} && rm #{remote_filename}" ensure FileUtils.rm filename rescue nil FileUtils.rm_rf destination rescue nil end |