How do I clear stuck/stale Resque workers?

后端 未结 15 795
你的背包
你的背包 2020-12-07 07:22

As you can see from the attached image, I\'ve got a couple of workers that seem to be stuck. Those processes shouldn\'t take longer than a couple of seconds.

15条回答
  •  情书的邮戳
    2020-12-07 07:56

    Adding to answer by hagope, I wanted to be able to only unregister workers that had been running for a certain amount of time. The code below will only unregister workers running for over 300 seconds (5 minutes).

    Resque.workers.each {|w| w.unregister_worker if w.processing['run_at'] && Time.now - w.processing['run_at'].to_time > 300}
    

    I have an ongoing collection of Resque related Rake tasks that I have also added this to: https://gist.github.com/ewherrmann/8809350

提交回复
热议问题