Created
March 27, 2012 16:49
-
-
Save seanbehan/2217848 to your computer and use it in GitHub Desktop.
Capistrano Multi Stage Deploy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'capistrano', '~> 2.11.2' | |
gem 'capistrano-ext', '~> 1.2.1' | |
gem 'capistrano_colors', '~> 0.5.5' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :domain, "example.com" | |
set :repository, "[email protected]: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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set :domain, "staging.example.com" | |
set :repository, "[email protected]: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