Automatically start a long-running process?

I need to run a query every 10 seconds or so on my DB, and take certain
actions if necessary. The way I’ve been doing this is to have a class
method that contains an infinite loop. I start this method with an init
script that calls script/runner. I’m wondering if there’s a better way
to do this - for instance, could I somehow start that method when my app
starts up and thread it out? What I have works, but it seems that there
should be a more graceful way to do it.
Jason

Jason N. wrote:

…I’m wondering if there’s a better way
to do this - for instance, could I somehow start that method when my app
starts up and thread it out?

Look at backgroundrb:

http://backgroundrb.rubyforge.org/

Even though it’s “not ready for prime time” according to the author(s),
I’ve been using the older version on a production site, with no problems
I couldn’t hack around, for about three months.

And the latest version is substantially better. It’s good stuff.

–Al Evans