Sha256: f74052cdba89b94f9321b7a268c3ce82a75c8baedaebc36d7b18fa43f5beca3f

Contents?: true

Size: 1.89 KB

Versions: 22

Compression:

Stored size: 1.89 KB

Contents

require 'capistrano/recipes/deploy/strategy/remote'

module Capistrano
  module Deploy
    module Strategy

      # Implements the deployment strategy that keeps a cached checkout of
      # the source code on each remote server. Each deploy simply updates the
      # cached checkout, and then does a copy from the cached copy to the
      # final deployment location.
      class RemoteCache < Remote
        # Executes the SCM command for this strategy and writes the REVISION
        # mark file to each host.
        def deploy!
          update_repository_cache
          copy_repository_cache
        end

        def check!
          super.check do |d|
            d.remote.command("rsync") unless copy_exclude.empty?
            d.remote.writable(shared_path)
          end
        end

        private

          def repository_cache
            File.join(shared_path, configuration[:repository_cache] || "cached-copy")
          end

          def update_repository_cache
            logger.trace "updating the cached checkout on all servers"
            command = "if [ -d #{repository_cache} ]; then " +
              "#{source.sync(revision, repository_cache)}; " +
              "else #{source.checkout(revision, repository_cache)}; fi"
            scm_run(command)
          end

          def copy_repository_cache
            logger.trace "copying the cached version to #{configuration[:release_path]}"
            if copy_exclude.empty?
              run "cp -RPp #{repository_cache} #{configuration[:release_path]} && #{mark}"
            else
              exclusions = copy_exclude.map { |e| "--exclude=\"#{e}\"" }.join(' ')
              run "rsync -lrpt #{exclusions} #{repository_cache}/ #{configuration[:release_path]} && #{mark}"
            end
          end

          def copy_exclude
            @copy_exclude ||= Array(configuration.fetch(:copy_exclude, []))
          end
      end

    end
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
capistrano-2.15.11 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.10 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.9 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.8 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.7 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.6 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.5 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
minmb-capistrano-2.15.4 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.4 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.3 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.2 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.15.1 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.14.2 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.14.1 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.13.5 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.12.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.11.2 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.9.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.8.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb