Class: Capistrano::Deploy::Strategy::RsyncWithRemoteCache

Inherits:
Remote
  • Object
show all
Defined in:
lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb

Constant Summary collapse

INFO_COMMANDS =
{
  :subversion => "svn info . | sed -n \'s/URL: //p\'",
  :git        => "git config remote.origin.url",
  :mercurial  => "hg showconfig paths.default",
  :bzr        => "bzr info | grep parent | sed \'s/^.*parent branch: //\'"
}

Instance Method Summary collapse

Instance Method Details

#check!Object

Defines commands that should be checked for by deploy:check. These include the SCM command on the local end, and rsync on both ends. Note that the SCM command is not needed on the remote end.



37
38
39
40
41
42
43
# File 'lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb', line 37

def check!
  super.check do |check|
    check.local.command(source.command)
    check.local.command('rsync')
    check.remote.command('rsync')
  end
end

#deploy!Object

The deployment method itself, in three major steps: update the local cache, update the remote cache, and copy the remote cache into place.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/capistrano/recipes/deploy/strategy/rsync_with_remote_cache.rb', line 18

def deploy!

  # Step 1: Update the local cache.
  system(command)
  File.open(File.join(local_cache, "REVISION"), "w") { |file| file.puts(revision) }

  # Step 2: Update the remote cache.
  logger.trace "copying local cache to remote"
  find_servers(:except => { :no_release => true }).each do |server|
    system("rsync #{rsync_options} --rsh='ssh -p #{ssh_port}' #{local_cache}/ #{rsync_host(server)}:#{repository_cache}/")
  end

  # Step 3: Copy the remote cache into place, excluding scm directories (for svn, git, cvs, bzr and more).
  run("rsync -a --cvs-exclude --delete #{repository_cache}/ #{configuration[:release_path]}/ && #{mark}")
end