Created
May 29, 2011 19:31
-
-
Save bsodmike/998069 to your computer and use it in GitHub Desktop.
Capistrano multistage deployment configuration. This example is deployed from the 'dev' branch.
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
#---------------------------------------------------------------------- | |
# Copyright (c) 2011, Michael de Silva <michael@mwdesilva.com> | |
# Blog: http://www.bsodmike.com ~ Twitter: @bsodmike | |
#---------------------------------------------------------------------- | |
set :stages, %w(production) | |
set :default_stage, "production" # this is not ideal | |
# it should be 'staging' by default | |
require 'capistrano/ext/multistage' # gem install capistrano-ext | |
set :application, "app.local" | |
# git source control | |
set :scm, :git | |
set :repository, "ssh://git@github.com/app-repo.git" | |
# best define branch in appropriate env file. | |
# set :branch, 'master' # default branch for deployment | |
set :use_sudo, false | |
set :deploy_to, "/home/appuser/sites/#{application}" | |
#set :deploy_via, :remote_cache # prevent each deploy doing a full | |
# repository clone for each deploy. | |
set :deploy_env, 'production' | |
set :scm_verbose, true | |
# login details | |
set :user, "appuser" | |
ssh_options[:forward_agent] = true | |
default_run_options[:pty] = true | |
server "linode.com", :app, :web, :db, :primary => true | |
# role :web, "your web-server here" # Your HTTP server, Apache/etc | |
# role :app, "your app-server here" | |
# role :db, "your primary db-server here", :primary => true | |
# # This is where Rails migrations will run | |
# role :db, "your slave db-server here" | |
task :uname do | |
run "uname -a" | |
end | |
# Default config for 'cap deploy:restart'. This prevents using the | |
# script/reaper helper as per https://gist.github.com/912747 | |
# If you are using Passenger mod_rails uncomment this: | |
# if you're still using the script/reapear helper you will need | |
# these http://github.com/rails/irs_process_scripts | |
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 | |
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
# Deploy with Capistrano | |
gem 'capistrano' | |
gem 'capistrano-ext' |
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
#---------------------------------------------------------------------- | |
# Copyright (c) 2011, Michael de Silva <michael@mwdesilva.com> | |
# Blog: http://www.bsodmike.com ~ Twitter: @bsodmike | |
#---------------------------------------------------------------------- | |
set :branch, 'dev' # branch for deployment | |
# If you are using Passenger mod_rails uncomment this: | |
# if you're still using the script/reapear helper you will need | |
# these http://github.com/rails/irs_process_scripts | |
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 | |
end | |
namespace :config do | |
desc "Symlink the database config file from shared directory to current release directory." | |
task :symlink_database_yml, :roles => :app do | |
run "ln -nsf #{shared_path}/config/database.yml #{release_path}/config/database.yml" | |
end | |
after 'deploy:update_code' , 'config:symlink_database_yml' | |
# 'deploy:update_code' takes place before 'deploy:restart' | |
# after "deploy", 'config:symlink_database_yml' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment