diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/tasks/resque.rake | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/tasks/resque.rake b/lib/tasks/resque.rake index 36e461da660..0c3b93c5bed 100644 --- a/lib/tasks/resque.rake +++ b/lib/tasks/resque.rake @@ -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)" |
