DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Capistrano: Deploy Rails Twice To The Same Machine
Capistrano is oriented so it deploys to the same directory on several machines. This means you can't deploy to two different locations on the same machine. The following recipe in Capfile will allow you to duplicate your main rails app in a second directory. You can schedule it to run automatically with every deploy or just do it manually. I included database migrations by default. Remove the shared config line if you don't have it. Edit the directories to match yours.
namespace :yournamespace do desc "Synchronize main_app to second_app" task :sync_apps, :roles => [:app, :db, :web] do puts "synchronizing main_app to second_app" run "rsync -a /var/rails/main_app/ /var/rails/second_app --exclude=/shared --delete" run "for file in `find /var/rails/second_app -type l`; do TARGET=`readlink $file | sed -e \"s/main_app/second_app/\"`; rm $file; ln -s $TARGET $file; done;" run "cp /var/rails/second_app/shared/config/* /var/rails/second_app/current/config"; run "cd /var/rails/second_app/current; /usr/local/bin/rake RAILS_ENV=production db:migrate;" run "touch tmp/restart.txt" end end