# This works in Capistrano 2.1 for Railsplayground.com for RoR application deployments as of Jan 27, 2008. I have the level 2 developer hosting plan and run two application instances in a Mongrel cluster starting on port 4008. I hope this helps someone.
set :main_account, "your_cpanel_login_name_goes_here"
set :application, "your_application_name_goes_here" # Can be whatever you want, I use the project name from my SVN repository
set :domain, "your_website_domain.com" # The URL for your app
set :user, "your_cpanel_login_name_goes_here" # Your HostingRails username
set :repository, "http://#{main_account}.svnrepository.com/svn/#{application}/trunk" # The repository location for svn+ssh access
set :scm_username, "your_svn_user_name_goes_here"
set :scm_password, "your_svn_password_goes_here"
set :use_sudo, false # HostingRails users don't have sudo access
set :deploy_to, "/home/#{user}/apps/#{application}" # Where on the server your app will be deployed
set :current, "#{deploy_to}/current"
set :deploy_via, :checkout # For this tutorial, svn checkout will be the deployment method
set :chmod755, "app config db lib public vendor script script/* public/disp*" # Some files that will need proper permissions
set :mongrel_port, "4008" # Mongrel port
set :mongrel_nodes, "2" # Number of Mongrel instances for those with multiple Mongrels
set :shared_directory, "#{deploy_to}/shared"
set :default_rails, "#{shared_directory}/default_rails_app" # This is a pristine "new" default rails application by typing in "rails default_rails_app".
set :modified_rails, "#{shared_directory}/modified_rails_app" # This is also an auto-generated rails application, but I allow myself to modfiy this one.
default_run_options[:pty] = true
ssh_options[:keys] = %w(/Path/To/id_rsa) # If you are using ssh_keys
role :app, domain
role :web, domain
role :db, domain, :primary => true
######################### Below is my corresponding Capfile ################################
namespace :deploy do
task :start, :roles => :app do
run "cd #{current_path} && mongrel_rails cluster::configure -e production -p #{mongrel_port}0 --pid "#{deploy_to}/shared/pids" -N #{mongrel_nodes} -c #{current_path} --user #{user} --group #{user}"
run "cd #{current_path} && mongrel_rails cluster::start"
run "rm -rf /home/#{user}/public_html;ln -s #{current_path}/public /home/#{user}/public_html"
run "mkdir -p #{deploy_to}/shared/config"
run "mv #{current_path}/config/mongrel_cluster.yml #{deploy_to}/shared/config/mongrel_cluster.yml"
run "ln -s #{deploy_to}/shared/config/mongrel_cluster.yml #{current_path}/config/mongrel_cluster.yml"
end
task :restart, :roles => :app do
run "ln -s #{deploy_to}/shared/config/mongrel_cluster.yml #{current_path}/config/mongrel_cluster.yml"
run "cd #{current_path} && mongrel_rails cluster::restart"
run "cd #{current_path} && chmod 755 #{chmod755}"
end
task :after_symlink, :roles => :app do
# I don't check the following files into my SVN because they are (potentially or actually) development box specific, server-specific, uninteresting to version, or take up a lot of disk space.
run "ln -s #{default_rails}/config/boot.rb #{current}/config/boot.rb"
run "ln -s #{default_rails}/config/environment.rb #{current}/config/environment.rb"
run "ln -s #{modified_rails}/config/environments #{current}/config/environments"
run "ln -s #{default_rails}/public/dispatch.cgi #{current}/public/dispatch.cgi"
run "ln -s #{default_rails}/public/dispatch.fcgi #{current}/public/dispatch.fcgi"
run "ln -s #{default_rails}/public/dispatch.rb #{current}/public/dispatch.rb"
run "cp -rf #{default_rails}/script #{current}/script"
run "ln -s "#{deploy_to}/shared/tmp #{current}/tmp"
run "chmod -R 755 #{current_path}/public"
end
end
# Caveats: These aren't my final deploy.rb/Capfiles, but they work for now. I still need to symbolically link to a shared images directory.
# Also, this is not a passwordless deployment. You need to put your password in once in the beginning by typing cap -p -- deploy.