Created
April 20, 2011 14:22
-
-
Save mlomnicki/931454 to your computer and use it in GitHub Desktop.
deploy.rb with rvm support
This file contains hidden or 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' | |
set :application, "multicomm" | |
set :repository, "git@XXXX" | |
set :scm, :git | |
set :user, 'multicomm' | |
set :deploy_to, '/var/lib/multicomm' | |
set :use_sudo, false | |
set :git_enable_submodules, 1 | |
role :web, "XXX" | |
role :app, "XXX" | |
role :db, "XXX", :primary => true | |
set :rvm_type, :user | |
$: << "#{File.join(ENV["HOME"], '.rvm/lib')}" | |
require 'rvm/capistrano' | |
set :rvm_ruby_string, 'ruby-1.9.2-p136' | |
after "deploy:update_code", "create_symlinks" | |
namespace :deploy do | |
desc "Restart the master unicorn process" | |
task :restart do | |
run "kill -HUP `cat #{deploy_to}/shared/pids/unicorn.pid`" | |
delayed_job::restart | |
end | |
task :start do | |
run "cd #{deploy_to}/current && bundle exec unicorn_rails -c config/unicorn.rb -E production -D" | |
end | |
task :stop do | |
run "kill -TERM `cat #{deploy_to}/shared/pids/unicorn.pid`" | |
end | |
end | |
namespace :delayed_job do | |
desc "Start delayed job workers" | |
task :start, :roles => :app do | |
run "cd #{current_path} && RAILS_ENV=production bundle exec script/delayed_job start -n 2" | |
end | |
desc "Stop delayed job workers" | |
task :stop, :roles => :app do | |
run "cd #{current_path} && RAILS_ENV=production bundle exec script/delayed_job stop" | |
end | |
desc "Restart delayed jobs (in the background)" | |
task :restart, :roles => :app do | |
delayed_job::stop | |
delayed_job::start | |
end | |
end | |
task :create_symlinks, :except => {:no_symlink => true} do | |
cmd = "cd #{release_path} &&\n" | |
cmd << "ln -nfs #{shared_path}/config/environments/production.rb #{release_path}/config/environments/production.rb &&" | |
cmd << "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml && " | |
cmd << "ln -nfs #{shared_path}/config/unicorn.rb #{release_path}/config/unicorn.rb && " | |
cmd << "ln -nfs releases/#{release_name} ../../relative_current" | |
run cmd | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment