Sha256: 3752102d272ff4cd715bd0a5ec142f90516b8349dedb31191e283c9ac46ef1c6

Contents?: true

Size: 1.45 KB

Versions: 8

Compression:

Stored size: 1.45 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]}"
            run "cp -RPp #{repository_cache} #{configuration[:release_path]} && #{mark}"
          end
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
capistrano-2.1.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.0.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.3.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.4.1 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.4.2 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.2.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.4.3 lib/capistrano/recipes/deploy/strategy/remote_cache.rb
capistrano-2.4.0 lib/capistrano/recipes/deploy/strategy/remote_cache.rb