[refs #510] Add resque recipes for capistrano
This commit is contained in:
parent
216b0da98e
commit
7d58937149
|
@ -37,6 +37,7 @@ require './lib/recipes/nginx'
|
|||
require './lib/recipes/unicorn'
|
||||
require './lib/recipes/bluepill'
|
||||
require './lib/recipes/delayed_job'
|
||||
require './lib/recipes/resque'
|
||||
|
||||
namespace :deploy do
|
||||
task :stub_xml_rpc do
|
||||
|
@ -89,6 +90,11 @@ after "deploy:stop", "delayed_job:stop"
|
|||
after "deploy:start", "delayed_job:start"
|
||||
after "deploy:restart", "delayed_job:restart"
|
||||
|
||||
# Resque
|
||||
after "deploy:stop", "resque:stop"
|
||||
after "deploy:start", "resque:start"
|
||||
after "deploy:restart", "resque:restart"
|
||||
|
||||
after "deploy:restart", "deploy:cleanup"
|
||||
|
||||
namespace :rake_tasks do
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
Capistrano::Configuration.instance(:must_exist).load do
|
||||
namespace :resque do
|
||||
task :start do
|
||||
start_workers
|
||||
end
|
||||
|
||||
task :stop do
|
||||
stop_workers
|
||||
end
|
||||
|
||||
task :restart do
|
||||
stop_workers
|
||||
start_workers
|
||||
end
|
||||
|
||||
def rails_env
|
||||
fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
|
||||
end
|
||||
|
||||
def start_workers
|
||||
pids = Array.new
|
||||
|
||||
Resque.workers.each do |worker|
|
||||
pids << worker.to_s.split(/:/).second
|
||||
end
|
||||
|
||||
if pids.size > 0
|
||||
system("kill -QUIT #{pids.join(' ')}")
|
||||
end
|
||||
end
|
||||
|
||||
def stop_workers
|
||||
run "cd #{fetch :release_path} && QUEUE=* bundle exec rake resque:work"
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue