Created
April 8, 2013 07:01
-
-
Save ryancheung/5334782 to your computer and use it in GitHub Desktop.
Capistrano config file example with Resque and Resque Scheduler
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 "rvm/capistrano" # Load RVM's capistrano plugin. | |
require "bundler/capistrano" | |
set :rvm_ruby_string, '1.9.3' | |
set :rvm_type, :user # Literal ":user" | |
set :application, "blog_test" | |
set :repository, "[email protected]:ryancheung/blog.git" | |
set :scm, :git | |
set :user, 'ryan' | |
set :use_sudo, false | |
set :deploy_to, "/var/apps/#{application}" | |
# set :scm, :git # You can set :scm explicitly or Capistrano will make an intelligent guess based on known version control directory names | |
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none` | |
role :web, "ubuntu-server" # Your HTTP server, Apache/etc | |
role :app, "ubuntu-server" # This may be the same as your `Web` server | |
role :db, "ubuntu-server", :primary => true # This is where Rails migrations will run | |
set :rails_env, 'production' | |
# if you want to clean up old releases on each deploy uncomment this: | |
after "deploy:restart", "deploy:cleanup" | |
# if you're still using the script/reaper helper you will need | |
# these http://github.com/rails/irs_process_scripts | |
namespace :deploy do | |
task :start, :roles => :app do | |
run "cd #{deploy_to}/current/; RAILS_ENV=#{rails_env} ./unicorn.sh start" | |
end | |
task :stop, :roles => :app do | |
run "cd #{deploy_to}/current/; RAILS_ENV=#{rails_env} ./unicorn.sh stop" | |
end | |
desc "Restart Application" | |
task :restart, :roles => :app do | |
run "cd #{deploy_to}/current/; RAILS_ENV=#{rails_env} ./unicorn.sh restart" | |
end | |
end | |
namespace :resque do | |
desc "Start resque worker" | |
task :start, :roles => :db do | |
run "cd #{deploy_to}/current/; RAILS_ENV=production PIDFILE=./tmp/pids/resque.pid BACKGROUND=yes QUEUE=* bundle exec rake resque:work" | |
end | |
desc "Stop resque worker" | |
task :stop, :roles => :db do | |
run "cd #{deploy_to}/current/; kill -QUIT $(cat ./tmp/pids/resque.pid)" | |
end | |
desc "Restart resque worker" | |
task :restart do | |
run "cd #{deploy_to}/current/; kill -QUIT $(cat ./tmp/pids/resque.pid)" | |
run "cd #{deploy_to}/current/; RAILS_ENV=production PIDFILE=./tmp/pids/resque.pid BACKGROUND=yes QUEUE=* bundle exec rake resque:work" | |
end | |
desc "Start resque scheduler worker" | |
task :start_scheduler, :roles => :db do | |
run "cd #{deploy_to}/current/; RAILS_ENV=production PIDFILE=./tmp/pids/resque_scheduler.pid BACKGROUND=yes QUEUE=* bundle exec rake resque:scheduler" | |
end | |
desc "Stop resque scheduler worker" | |
task :stop_scheduler, :roles => :db do | |
run "cd #{deploy_to}/current/; kill $(cat ./tmp/pids/resque_scheduler.pid)" | |
end | |
desc "Restart resque scheduler worker" | |
task :restart_scheduler, :roles => :db do | |
run "cd #{deploy_to}/current/; kill $(cat ./tmp/pids/resque_scheduler.pid)" | |
run "cd #{deploy_to}/current/; RAILS_ENV=production PIDFILE=./tmp/pids/resque_scheduler.pid BACKGROUND=yes QUEUE=* bundle exec rake resque:scheduler" | |
end | |
end | |
after "deploy:restart", "resque:restart" | |
after "resque:restart", "resque:restart_scheduler" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment