Capistrano For ChiliProject

Johan Bruning asked me to share the capistrano configuration I’m using for ChiliProject. This is the exact version I’m using to deploy Little Stream Software’s ChiliProject.

Download this file

require "bundler/capistrano"
 
set :application, "chiliproject"
set :repository, "git@projects.littlestreamsoftware.app.git"
set :scm, :git
set :git_enable_submodules,1
 
# fast_remote_cache is better but requires a plugin
set :deploy_via, :remote_cache
# set :deploy_via, :fast_remote_cache
 
# =============================================================================
# OPTIONAL VARIABLES
# =============================================================================
set :deploy_to, "/home/websites/projects.littlestreamsoftware.com" # defaults to "/u/apps/#{application}"
set :user, "edavis"            # defaults to the currently logged in user
set :use_sudo, false
 
# =============================================================================
# SSH OPTIONS
# =============================================================================
ssh_options[:forward_agent] = true
 
default_run_options[:pty] = true
 
# Is sent to bundler so only production and postgres bundles are created
set :bundle_without, [:development, :test, :rmagick, :mysql, :mysql2, :sqlite]
 
namespace :deploy do
  desc "Restarting mod_rails with restart.txt"
  task :restart, :roles => :app, :except => { :no_release => true } do
    run "touch #{current_path}/tmp/restart.txt"
  end
 
  [:start, :stop].each do |t|
    desc "#{t} task is a no-op with mod_rails"
    task t, :roles => :app do ; end
  end
 
  desc "Migrate the plugins"
  task :migrate_plugins, :roles => [:app] do
    run "cd #{current_path} && rake RAILS_ENV=production  db:migrate_plugins"
  end
end
 
namespace :localize do
  desc "copy shared configurations to current"
  task :copy_shared_configurations, :roles => [:app] do
    %w[database.yml configuration.yml additional_environment.rb].each do |f|
      run "ln -nsf #{shared_path}/config/#{f} #{current_path}/config/#{f}"
    end
  end
 
  desc "link shared file storage to current"
  task :link_shared_file_storage, :roles => [:app] do
    run "ln -nsf #{shared_path}/files/ #{current_path}/files"
  end
 
  desc "link session store configuration"
  task :link_session_store, :roles => [:app] do
    run "ln -nsf #{shared_path}/config/session_store.rb #{current_path}/config/initializers/session_store.rb"
  end
end
 
after "deploy:symlink", "localize:copy_shared_configurations", "localize:link_shared_file_storage", "localize:link_session_store", "deploy:cleanup"