Skip to content

Instantly share code, notes, and snippets.

@seanbehan
Created March 27, 2012 16:49
Show Gist options
  • Save seanbehan/2217848 to your computer and use it in GitHub Desktop.
Save seanbehan/2217848 to your computer and use it in GitHub Desktop.
Capistrano Multi Stage Deploy
require 'bundler/capistrano'
require 'capistrano/ext/multistage'
require 'capistrano_colors'
set :stages, %w(staging production)
set :default_stage, "staging"
set :user, "webapp"
set :ssh_option, {:forward_agent => true}
set :application, "application-name"
set :deploy_via, :remote_cache
set :scm, :git
set :use_sudo, false
default_run_options[:pty] = true
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
end
def surun(command)
password = fetch(:root_password, Capistrano::CLI.password_prompt("root password: "))
run("sudo #{command}") do |channel, stream, output|
channel.send_data("#{password}\n") if output
end
end
end
gem 'capistrano', '~> 2.11.2'
gem 'capistrano-ext', '~> 1.2.1'
gem 'capistrano_colors', '~> 0.5.5'
set :domain, "example.com"
set :repository, "git@github.com:organization-name/repository-name.git"
set :app_dir, "#{application}"
set :deploy_to, "/home/webapp/#{app_dir}"
set :branch, "master"
set :rails_env, "production"
server "#{domain}", :web, :app, :db, :primary => true
set :domain, "staging.example.com"
set :repository, "git@github.com:organization-name/repository-name.git"
set :app_dir, "#{application}"
set :deploy_to, "/home/webapp/#{app_dir}"
set :branch, "development"
set :rails_env, "staging"
server "#{domain}", :web, :app, :db, :primary => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment