On Fri, Feb 26, 2010 at 7:53 PM, Mat Brown <mat / patch.com> wrote:

> Check out resque-scheduler:
>
> http://github.com/bvandenbos/resque-scheduler
>
> Generally you'll want to use a standalone daemon to do any sort of
> background work; doing it in threads / forking considered harmful in
> Rails.
>
> Mat
>
> On Fri, Feb 26, 2010 at 14:50, Nick Brown <nick / nick-brown.com> wrote:
> > What is the best way to schedule something for delayed asynchronous
> > execution? Basically, I want to say "in 20 seconds, execute this
> > function / block / proc / lambda / webhook or whatever".
> >
> > Also: this will be used by a rack-based web app, so I need a solution
> > that will keep working if Passenger restarts instances of the
> > application. Would a Thread.new(delay) {|delay| sleep delay; ...} type
> > of solution work in such a scenario? Does using Thread like this consume
> > lots of memory?
> >
> > How have you solved this in the past? I would like to avoid installing
> > daemons if possible.
>

Nick,
there's a lot of options out there, virtually all of them use a background
process and
are not thread based. You got BackgroundRb, Workling, Starling, DelayedJob
etc.

There are a lot of implementations of this (too many IMO, it would be nice
to see
some kind of emergent winner here, this is a very common activity).

They tend to differentiate on their core implementation technologies: cron
based,
table based, memcache based, Queue based etc.

There are a couple of writeups comparing them. I would go check them out.
(Sorry I dont have any links to hand)

-- 
http://richardconroy.blogspot.com