How to destroy jobs enqueued by resque workers?

前端 未结 7 1956
日久生厌
日久生厌 2021-01-30 05:22

I\'m using Resque on a rails-3 project to handle jobs that are scheduled to run every 5 minutes. I recently did something that snowballed the creation of these jobs and the stac

相关标签:
7条回答
  • 2021-01-30 05:44

    If you pop open a rails console, you can run this code to clear out your queue(s):

    queue_name = "my_queue"
    Resque.redis.del "queue:#{queue_name}"
    
    0 讨论(0)
  • 2021-01-30 05:51

    This is what works now:

    Resque.remove_queue("...")
    
    0 讨论(0)
  • 2021-01-30 05:52

    Updated rake task for clearing (according to latest redis commands changes): https://gist.github.com/1228863

    0 讨论(0)
  • 2021-01-30 05:54

    Playing off of the above answers, if you need to clear all of your queues, you could use the following:

    Resque.queues.each{|q| Resque.redis.del "queue:#{q}" }
    
    0 讨论(0)
  • 2021-01-30 06:01

    Resque already has a method for doing this - try Resque.remove_queue(queue_name) (see the documentation here). Internally it performs Resque.redis.del(), but it also does other cleanup, and by using an api method (rather than making assumptions about how resque works) you'll be more future-proof.

    0 讨论(0)
  • 2021-01-30 06:05

    It's safer and bulletproof to use the Resque API rather than deleting everything on the Resque's Redis. Resque does some cleaning in the inside.

    If you want to remove all queues and associated enqueued jobs:

    Resque.queues.each {|queue| Resque.remove_queue(queue)}
    

    The queues will be re-created the next time a job is enqueued.

    Documentation

    0 讨论(0)
提交回复
热议问题