Created
January 14, 2013 19:09
-
-
Save dgilperez/4532453 to your computer and use it in GitHub Desktop.
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
# https://gist.github.com/1623632 | |
# bundler bootstrap | |
require 'bundler/capistrano' | |
# main details | |
set :application, "123" | |
role :web, "#{application}.cloud.voupe.net" # #{application}.cloud.voupe.net | |
role :app, "#{application}.cloud.voupe.net" | |
role :db, "#{application}.cloud.voupe.net", :primary => true | |
# server details | |
default_run_options[:pty] = true | |
ssh_options[:forward_agent] = true | |
set :deploy_to, "/opt/apps/#{application}" | |
set :deploy_via, :remote_cache | |
set :user, "deploy" | |
set :use_sudo, false | |
# repo details | |
set :scm, :git | |
set :scm_username, "deploy" | |
set :repository, "[email protected]:voupe/#{application}/app.git" | |
set :branch, "master" | |
set :git_enable_submodules, 1 | |
namespace :deploy do | |
desc "Tell Passenger to restart." | |
task :restart, :roles => :web do | |
run "touch #{deploy_to}/current/tmp/restart.txt" | |
end | |
desc "Do nothing on startup so we don't get a script/spin error." | |
task :start do | |
puts "You may need to restart Apache." | |
end | |
desc "Symlink extra configs and folders." | |
task :symlink_extras do | |
run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml" | |
end | |
desc "Setup shared directory." | |
task :setup_shared do | |
run "mkdir #{shared_path}/config" | |
put File.read("config/examples/database.yml"), "#{shared_path}/config/database.yml" | |
puts "Now edit the config files in #{shared_path}." | |
end | |
desc "Make sure there is something to deploy" | |
task :check_revision, :roles => :web do | |
unless `git rev-parse HEAD` == `git rev-parse origin/master` | |
puts "WARNING: HEAD is not the same as origin/master" | |
puts "Run `git push` to sync changes." | |
exit | |
end | |
end | |
desc "Compile assets" | |
task :assets_precompile, :roles => :app do | |
run "cd #{release_path}; RAILS_ENV=production bundle exec rake assets:precompile" | |
end | |
end | |
before "deploy", "deploy:check_revision" | |
after "deploy", "deploy:cleanup" # keeps only last 5 releases | |
after "deploy:setup", "deploy:setup_shared" | |
after "deploy:update_code", "deploy:symlink_extras" | |
after "deploy:symlink_extras", "deploy:assets_precompile" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment