Created
March 7, 2013 16:44
-
-
Save dugsmith/5109521 to your computer and use it in GitHub Desktop.
Capistrano Recipe to RSync from build server to app server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :repository, '.' | |
set :scm, :none | |
set :deploy_via, :copy | |
set :user, 'your-user-name' | |
set :deploy_to, "your/application/dir" | |
namespace :deploy do | |
desc <<-DESC | |
Update all servers with the latest release of the source code. | |
Since production servers do not have access to SCM, we use | |
rsync to push to code to the servers. | |
DESC | |
task :update_code, :roles => [:app, :web] do | |
on_rollback { run "rm -rf #{release_path}; true" } | |
username = user || ENV['USER'] | |
run <<-CMD | |
rsync -avz -e ssh '#{Dir.pwd}/' \ | |
'#{username}@$CAPISTRANO:HOST$:#{release_path}' \ | |
--exclude 'log' \ | |
--exclude 'tmp' | |
--exclude 'public/assets' \ | |
--exclude 'public/files' \ | |
--exclude 'public/system' | |
CMD | |
run <<-CMD | |
rsync -avz -e ssh '#{Dir.pwd}/../../shared/assets/' \ | |
'#{username}@$CAPISTRANO:HOST$:#{shared_path}/assets' | |
CMD | |
run <<-CMD | |
rsync -avz -e ssh '#{Dir.pwd}/../../shared/bundle/' \ | |
'#{username}@$CAPISTRANO:HOST$:#{shared_path}/bundle' | |
CMD | |
run <<-CMD | |
ln -nfs #{shared_path}/log #{release_path}/log && | |
ln -nfs #{shared_path}/assets #{release_path}/public/assets && | |
ln -nfs #{shared_path}/files #{release_path}/public/files && | |
ln -nfs #{shared_path}/system #{release_path}/public/system | |
CMD | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment