views:

265

answers:

2

I have a backroundrb scheduled task that takes quite a long time to run. However it seems that the process is ending after only 2.5 minutes.

My background.yml file:

:schedules:
  :named_worker:
    :task_name:
      :trigger_args: 0 0 12 * * * *
      :data: input_data

I have zero activity on the server when the process is running. (Meaning I am the only one on the server watching the log files do their thing until the process suddenly stops.)

Any ideas?

+3  A: 

There's not much information here that allows us to get to the bottom of the problem. Because backgroundrb operates in the background, it can be quite hard to monitor/debug.

Here are some ideas I use:

  1. Write a unit test to test the worker code itself and make sure there are no problems there
  2. Put "puts" statements at multiple points in the code so you can at least see some responses while the worker is running.
  3. Wrap the entire worker in a begin..rescue..end block so that you can catch any errors that might be occurring and cutting the process short.
Andrew
You can also experiment with the code in question in the console (running it deliberately instead of waiting for it to run in the background) to watch things happen.
Ian Terrell
A: 

Thanks Andrew. Those debugging tips helped. Especially the begin..rescue..end block.

It was still a pain to debug though. In the end it wasn't BackgroundRB cutting short after 2.5 minutes. There was a network connection being made that wasn't being closed properly. Once that was found and closed, everything works great.

salt.racer