lib/tasks/resque.rake
# kills registered workers once they go idle
kills registered workers once they go idle
kills registered workers once they go idle
def stop_workers
    workers = Resque.workers
    until workers.empty? do
      workers.each_index do |i|
        w = workers[i]
        pid = w.pid
        if w.idle?
          workers.delete_at(i)
          puts "Stopping worker #{pid}..."
          w.unregister_worker
          system("kill #{pid}")
        else
          puts "Waiting for worker #{pid} to go idle..."
          sleep 1
          next
        end
      end
    end
  end
def stop_workers workers = Resque . workers until workers . empty? do workers . each_index do | i | w = workers [ i ] pid = w . pid if w . idle? workers . delete_at ( i ) puts "Stopping worker #{pid}..." w . unregister_worker system ( "kill #{pid}" ) else puts "Waiting for worker #{pid} to go idle..." sleep 1 next end end end end
kills registered workers once they go idle
kills registered workers once they go idle