Skip to content

Instantly share code, notes, and snippets.

@davidcornu
Created May 3, 2012 03:07
Show Gist options
  • Save davidcornu/2582734 to your computer and use it in GitHub Desktop.
Save davidcornu/2582734 to your computer and use it in GitHub Desktop.
Capfile
require 'bundler/capistrano'
server '69.164.216.145', :web, :app, :db, :primary => true
set :application, 'Ambrosia-Core'
set :user, 'deployer'
set :deploy_to, "/var/www/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, :git
set :repository, "[email protected]:davidcornu/#{application}.git"
set :branch, 'production'
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
default_environment["RAILS_ENV"] = 'production'
after 'deploy', 'deploy:cleanup' # keep only the last 5 releases
after 'deploy', 'resque:stop', 'resque:start' # restart the resque worker
after 'deploy:cold', 'resque:start' # start the resque worker
namespace :deploy do
desc "Start Unicorn server"
task :start, :roles => :app, :except => {:no_release => true} do
run "cd #{current_path}; bundle exec unicorn -c #{current_path}/config/unicorn.rb -D"
end
desc "Stop Unicorn server"
task :stop, :roles => :app, :except => {:no_release => true} do
run "cd #{current_path}; kill -QUIT `cat #{current_path}/tmp/pids/unicorn.pid`"
end
desc "Restart Unicorn server"
task :restart, :roles => :app, :except => {:no_release => true} do
run "cd #{current_path}; kill -USR2 `cat #{current_path}/tmp/pids/unicorn.pid`"
end
end
namespace :resque do
desc "Start Resque worker"
task :start, :roles => :app, :except => {:no_release => true} do
run "cd #{current_path}; bundle exec script/resque start"
end
desc "Stop Resque worker"
task :stop, :roles => :app, :except => {:no_release => true} do
run "cd #{current_path}; bundle exec script/resque stop"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment