Use gitlab resque fork. Added rake task to stop all workers

This commit is contained in:
Dmitriy Zaporozhets 2012-12-26 11:18:38 +02:00
parent 3b1519da47
commit 5cd823847b
3 changed files with 29 additions and 14 deletions

View file

@ -1,7 +1,22 @@
require 'resque/tasks'
task "resque:setup" => :environment do
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
namespace :resque do
task setup: :environment do
Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection }
end
desc "Resque | kill all workers (using -QUIT), god will take care of them"
task :stop_workers => :environment do
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
end
desc "Alias for resque:work (To run workers on Heroku)"