[Backgroundrb-devel] cron like behaviour?

Mason Hale masonhale at gmail.com
Wed Feb 14 11:34:18 EST 2007


Ivor -

Sounds like BackgroundRb is a good solution for your problem.
You define scheduled jobs in a file /config/backgroundrb_schedules.yml
-- these will get fired off on the interval you set.

Here's what my backgroundrb_schedules.yml looks like:

scheduled_publisher:
  :class: :scheduled_publish_worker
  :job_key: :scheduled_publisher
  :worker_method: :do_publish
  :worker_method_args: scheduled workers require some args, so here you go...
  :trigger_args:
      :start: <%= Time.now + 5.seconds %>
      :repeat_interval: <%= 1.minutes %>

This kicks off a worker that checks for pending publications every minute.

Note the :worker_method_args -- field. I found that if you do not
provide a value for this field your scheduled worked won't run. My
scheduled_publish_worker doesn't need any args -- so I provided a
placeholder value for :worker_method_args.

Mason
On 2/14/07, Ivor Paul <ivorpaul at gmail.com> wrote:
> Hi
>
> I have previously used railscron for server-side manipulation of the
> database but had a heap of trouble working with it.
> BackgrounDRB was suggested to me by a friend.
>
> I upload some files via acts_as_attachment and these go lie in a dir
> structure that i desire. What I want from the background process is to
> periodically (not user initiated) do some file-structure manipulation i.e. I
> want to move some of the files into different directory structures/create
> symlinks from different locations.
>
> What bugs me is how I get a worker to do_some_work without a user event.
>
> I will greatly appreciate some pointers.
>
> Thanks a lot.
> Ivor
>
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>


More information about the Backgroundrb-devel mailing list