Hey, I said I was going to do this a few days ago, but I work has
been hectic. I haven't really had a chance to do this properly, but I
thought I'd post what I hacked up but haven't had a chance to run
never mind test. Hopefully this will kick someone into making it
actually work.
There are two bits of code here, the first is kinda useless, but for
illustration, the second is hopefully more useful.
Firstly, we currently have a hacked together :remote_cache thing, and
for some reason that uses rsync to copy the cache to the release dir.
When we actually tested, cp was faster for a local copy operation.
For illustration, here's how I'd duplicate our current setup:
module Capistrano
module Deploy
module Strategy
class RemoteCacheWithRsync < RemoteCache
private
def copy_repository_cache
logger.trace "copying the cached version to #{configuration
[:release_path]}"
run "rsync -ax --exclude '.svn/' #{repository_cache}/ #
{configuration[:release_path]}/ && #{mark}"
end
end
end
end
end
If you wanted to use rsync for the remote copy then this is the not
ran, untested, think it should work but who knows code:
require 'capistrano/recipes/deploy/strategy/base'
module Capistrano
module Deploy
module Strategy
# This class implements the strategy for deployments which work
# by preparing the source code locally, and rsyncing it to the
remote
# server
#
# 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.
#
class Rsync < Base
# Obtains a copy of the source code locally (via the
#command method),
# and rsyncs it to the remote hosts
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 "rsyncing #{destination} to #{configuration
[:release_path]}"
find_servers(:roles => :app, :except => { :no_release =>
true }).each do |server|
system("rsync -az #{destination}/ #{server.host}:#
{configuration[:release_path]}/")
end
ensure
FileUtils.rm_rf destination rescue nil
end
def check!
super.check do |d|
d.local.command(source.command)
# TODO: Check for rsync
end
end
private
# Returns the basename of the release_path, which will be
used to
# name the local copy and archive file.
def destination
@destination ||= File.basename(configuration
[:release_path])
end
# Returns the value of the :copy_strategy variable,
defaulting to
# :checkout if it has not been set.
def copy_strategy
@copy_strategy ||= configuration.fetch
(:copy_strategy, :checkout)
end
# Should return the command(s) necessary to obtain the
source code
# locally.
def command
@command ||= case copy_strategy
when :checkout
source.checkout(revision, destination)
when :export
source.export(revision, destination)
end
end
end
end
end
end
Hope this helps/inspires someone, really wish I'd more time to give
to it.
Cheers,
Chris
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---