Sha256: 557cdbc7b6e9b2c4f8c0756671285a428d09bdd5add1b315a72f304bcc54d7e7

Contents?: true

Size: 1.84 KB

Versions: 51

Compression:

Stored size: 1.84 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.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

51 entries across 51 versions & 7 rubygems

Version Path
wulffeld-capistrano-2.5.8.3 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
mbailey-capistrano-2.5.5 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
mbailey-capistrano-2.5.6 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
mbailey-capistrano-2.5.7 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
sneakin-capistrano-2.5.5 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
thoughtbot-capistrano-2.5.5 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
thoughtbot-capistrano-2.5.6 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
wulffeld-capistrano-2.5.8.1 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
wulffeld-capistrano-2.5.8 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.024 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.023 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.022 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.021 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.020 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.019 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.018 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.017 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.016 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.015 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
le1t0-capistrano-2.5.18.014 lib/capistrano/recipes/deploy/strategy/remote_cache.rb