views:

141

answers:

1

We run an application with a half dozen mongrels. A new feature that we've added is a scheduler (rufus-scheduler) that runs within a mongrel and provides cron-like background task processing. We want ot run this scheduler on only one of our mongrels but we can't figure out how -- during startup (environment.rb) -- to identify the specific mongrel to start the scheduler in.

We have set up a yaml file with a setting for the port # for the mongrel in which we would like to have the scheduler start. During startup, in enviromnent.rb, we would like to query the yaml file, get the port, and then compare this to the instance that is booting -- if it's the same, launch the scheduler.

Someone answered recently that we should look at request.port -- there is no request object when you are booting. Where else is the port # stored? Or, how can we pass a parm to an individual mongrel or have it compare itself to a setting to identify itself?

Thanks in advance...

Russell

A: 

I asked the same question couple of weeks back.

Gist:

  1. A plugin named 'Rooster' addresses this problem.
  2. Use a shared resource like a file as a way to synchronize.
Swanand