Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6613321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:12:18+00:00 2026-05-25T20:12:18+00:00

I have a god/resque setup that spans a few worker servers. Every so often,

  • 0

I have a god/resque setup that spans a few worker servers. Every so often, the workers get jammed up by long polling connections and won’t time out correctly. We have tried coding around it (but regardless of why it doesn’t work), the keep-alive packets being sent down the wire won’t let us time it out easily.

I would like certain workers (which I already have segmented out in their own watch blocks) to not be allowed to run for longer than a certain amount of time. In pesudocode, I am looking for a watch condition like the following (i.e. restart that worker if it takes longer than 60 sec to complete the task):

w.transition(:up, :restart) do |on|
  on.condition(:process_timer) do {|c|  c.greater_than = 60.seconds}
end

Any thoughts or pointers on how to accomplish this would be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:12:18+00:00Added an answer on May 25, 2026 at 8:12 pm

    As it turns out, there is an example of how to do this in some sample resque files. It’s not exactly what I was looking for since it doesn’t add an on.condition(:foo), but it is a viable solution:

    # This will ride alongside god and kill any rogue stale worker
    # processes. Their sacrifice is for the greater good.
    
    WORKER_TIMEOUT = 60 * 10 # 10 minutes
    
    Thread.new do
      loop do
        begin
          `ps -e -o pid,command | grep [r]esque`.split("\n").each do |line|
            parts   = line.split(' ')
            next if parts[-2] != "at"
            started = parts[-1].to_i
            elapsed = Time.now - Time.at(started)
    
            if elapsed >= WORKER_TIMEOUT
              ::Process.kill('USR1', parts[0].to_i)
            end
          end
        rescue
          # don't die because of stupid exceptions
          nil
        end
    
        # Sleep so we don't run too frequently
        sleep 30
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class that I am monitoring using god. This is it's structure:
I have a large project that is quite a mess. There's God classes, poor
God, Linq confuses me... I've found quite a few examples that do similar things
I am trying to have God monitor two instances of Resque, one for production
We have many long-running processes that each require dozens of steps. Each step is
Have a n-tire web application and search often times out after 30 secs. How
Have you managed to get Aptana Studio debugging to work? I tried following this,
Oh god this must be so simple. I have a heading in range (0,
some comments here have confused me! I thought I knew this and god knows
I have a Python program that takes around 10 minutes to execute. So I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.