2011-12-12 23:03:38 +01:00
|
|
|
require 'resque/tasks'
|
2012-10-08 22:19:07 +02:00
|
|
|
|
2012-12-26 10:18:38 +01:00
|
|
|
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
|
2012-10-08 22:19:07 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Alias for resque:work (To run workers on Heroku)"
|
|
|
|
task "jobs:work" => "resque:work"
|