[Backgroundrb-devel] Multiple Worker Classes

Adam Williams adam at thewilliams.ws
Mon Mar 16 16:44:18 EDT 2009


Hello,

I had multiple worker classes, each set to load once. Some were adding  
periodic executions, some had scheduled work. I've discovered that  
this means there will be a worker process for each class. In an effort  
to get down to just one worker process (memory consumption was  
unaffordable), I have moved ALL work methods into one class. None of  
the methods assign any instance variables. Three of them are run  
periodically, three of them are scheduled.

   def create(args = nil)
     add_periodic_timer(1.minute)  { deliver_reminders }
     add_periodic_timer(2.minutes) { process_emails }
     add_periodic_timer(3.minutes) { deliver_invitations }

   backgroundrb.yml
     :schedules:
       :single_worker:
         :deliver_hub_member_joins:
           :trigger_args: '59 59 23 * * * *'
         :deliver_expiration_reminders:
           :trigger_args: '59 59 23 * * * *'
         :deliver_trial_ending_reminders:
           :trigger_args: '59 59 23 * * * *'

Is there anything I should be aware of with this kind of  
configuration? Anything that I should expect to fail?

On another note, I have the schedules as "59 59 23 * * * *" because  
last weekend backgroundrb began to run "0 0 0 * * * *" as 'every  
second' instead of as 'midnight'. I looked at the tests for the cron  
scheduler code, and there isn't one for "0 0 0 * * * *"; also, most of  
the other cron tests failed too. Worked great for months, then we went  
from -5GMT to -4GMT. Coincidence?

Thanks for a great tool!

   adam


More information about the Backgroundrb-devel mailing list