Skip to content

Instantly share code, notes, and snippets.

@jondkinney
Created September 20, 2011 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jondkinney/1228276 to your computer and use it in GitHub Desktop.
Save jondkinney/1228276 to your computer and use it in GitHub Desktop.
# Capistrano Multistage Support
# Uncomment the following lines if you'd like Multistage Capistrano support.
set :default_stage, "staging"
set :stages, %w(production staging alpha)
require 'capistrano/ext/multistage'
require 'capistrano/gitflow' # needs to come after multistage
# Include Bundler Extensions
# Comment out the following line if you're not using Bundler.
require "bundler/capistrano"
# RVM Settings
# Use either the latest RVM settings, or the legacy settings depending on your local RVM version.
# Must have latest version of RVM as of 12/8/2010 to make this work properly.
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require "rvm/capistrano"
set :rvm_ruby_string, "ruby-1.9.2-p290"
set :rvm_type, :system
# Server Settings
set :ssh_options, { :forward_agent => true }
# Comment this out if you're using Multistage support.
set :user, "deploy"
set :server_name, "dev01.c45431.blueboxgrid.com"
role :app, server_name
role :web, server_name
role :db, server_name, :primary => true
# Application Settings
set :application, "bolstr"
set :deploy_to, "/home/deploy/rails_apps/#{application}"
# Repo Settings
set :repository, "git@intridea.unfuddle.com:intridea/bolstr.git"
set :scm, "git"
set :checkout, 'export'
set :copy_exclude, ".git/*"
set :deploy_via, :remote_cache
# General Settings
default_run_options[:pty] = true
set :keep_releases, 5
set :use_sudo, false
# Hooks
before "deploy", "deploy:setup_ssh"
after "deploy", "deploy:cleanup"
after "deploy:update_code", "deploy:web:update_maintenance_page"
after "deploy:update_code", "deploy:secondary_symlink"
namespace :deploy do
desc "shell out and setup the keys so they can be forwarded"
task :setup_ssh, :except => { :no_release => true } do
`ssh-add`
end
task :secondary_symlink, :except => { :no_release => true } do
# Database
run "rm -f #{release_path}/config/database.yml"
run "ln -s #{deploy_to}/shared/config/database.yml #{release_path}/config/database.yml"
# .rvmrc
run "rm -f #{release_path}/.rvmrc"
end
task :restart, :except => { :no_release => true } do
run "touch #{deploy_to}/current/tmp/restart.txt"
end
task :start, :except => { :no_release => true } do
run "touch #{deploy_to}/current/tmp/restart.txt"
end
end
# Disable the built in disable command and setup some intelligence so we can have images.
disable_path = "#{shared_path}/system/maintenance/"
namespace :deploy do
namespace :web do
desc "Disables the website by putting the maintenance files live."
task :disable, :except => { :no_release => true } do
on_rollback { run "mv #{disable_path}index.html #{disable_path}index.disabled.html" }
run "mv #{disable_path}index.disabled.html #{disable_path}index.html"
end
desc "Enables the website by disabling the maintenance files."
task :enable, :except => { :no_release => true } do
run "mv #{disable_path}index.html #{disable_path}index.disabled.html"
end
desc "Copies your maintenance from public/maintenance to shared/system/maintenance."
task :update_maintenance_page, :except => { :no_release => true } do
run "rm -rf #{shared_path}/system/maintenance/; true"
run "mkdir -p #{release_path}/public/maintenance"
run "touch #{release_path}/public/maintenance/index.html.disabled"
run "cp -r #{release_path}/public/maintenance #{shared_path}/system/"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment