[Backgroundrb-devel] Newbie question on Scheduling
hemant
gethemant at gmail.com
Tue Jan 22 03:59:04 EST 2008
Hi,
On Jan 22, 2008 5:33 AM, steef nobody <swertyui at gmail.com> wrote:
> I've scheduled cron jobs etc before, but I'm curious as to how to layout a
> worker properly. Here's a basic example of what one of my workers looks
> like:
>
> class FooWorker < BackgrounDRb::MetaWorker
>
> set_worker_name :foo_worker
> def create(args = nil)
> logger.info("Starting test: #{Time.now.strftime("%T")}")
> run_test
> logger.info("Finished test: #{Time.now.strftime("%T")}")
> exit
> end
> def run_test
> logger.info("aaaa")
> sleep(30)
> logger.info("bbbb")
> end
> end
Never use sleep() in workers, its calling for trouble.
>
> I'd set my workers up like this while I was testing things. I'd modify them
> and restart backgroundrb to see how things went. I have things where I want
> them to be now, and am trying to get them scheduled properly.
>
> Let's say I wanted the above worker to run every day at 16:00. How would
> that look in my backgroundrb.yml file? Should I keep things out of the
> create method? The documentation seems to suggest I create my own methods
> and schedule each individually without calling exit to kill the worker.
You can use cron styled scheduling with trigger option:
0 0 16 * * * *
More information about the Backgroundrb-devel
mailing list