How do I clear stuck/stale Resque workers?

后端 未结 15 758
你的背包
你的背包 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

    0 讨论(0)
  • 2020-12-07 07:56

    If you use Docker, you can also use this command:

    <id> is the worker id.

    docker stop <id>
    
    docker start <id>
    
    0 讨论(0)
  • 2020-12-07 07:59

    Run this command wherever you ran the command to start the server

    $ ps -e -o pid,command | grep [r]esque
    

    you should see something like this:

    92102 resque: Processing ProcessNumbers since 1253142769
    

    Make note of the PID (process id) in my example it is 92102

    Then you can quit the process 1 of 2 ways.

    • Gracefully use QUIT 92102

    • Forcefully use TERM 92102

    * I'm not sure of the syntax it's either QUIT 92102 or QUIT -92102

    Let me know if you have any trouble.

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