[Catalyst] Taking advantage of idle periods by performing some action(s)

Ido Perlmuter ido at ido50.net
Thu Mar 25 15:04:38 GMT 2010


Kiffin, thanks for the heads up about Plugin::Scheduler, seems to fit my
needs quite good.

Bill, an outside worker is actually the heavier solution in this case,
because I'm not loading my Catalyst app just to run some code, my Catalyst
app is _always_ running (for the matter, it's a FastCGI process that is the
backend of my websites). Starting an external worker that needs to connect
to the schema and try hard to figure out what's going on in the already
running Catalyst process is pointless, hard to implement and kinda ugly (in
my opinion). My app is already up and running, why start a new process? it's
those idle moments when nobody seems to visit my stupid websites that I want
the app to employ itself with some useful tasks.

The location of the logic the app will be executing in those idle moments
(either the model or the controller itself) is irrelevant here. The
controller, which will be automatically requested at some idle moment, will
pass the work to the model...

Thanks,
Ido.

On Thu, Mar 25, 2010 at 4:01 PM, Bill Moseley <moseley at hank.org> wrote:

>
>
> On Thu, Mar 25, 2010 at 5:30 AM, Ido Perlmuter <ido at ido50.net> wrote:
>
>> I'm looking for direction on how to possibly implement a feature in a
>> Catalyst app that automatically performs some action, or actions, when t=
he
>> app is idle and hasn't been accepting requests (either none or some small
>> number). For example, let's say I want my app to take advantage of such
>> situations by indexing documents to KinoSearch, rebuilding a sitemap.xml
>> file, whatever.
>>
>
> Doesn't really seems like the job of a Catalyst app to run background
> tasks.
>
> What's wrong with cron?  It can run a script and see if the machine's load
> is low (or some other measurement) before deciding to run.
>
>
>
>> Thing is, I do not want (if possible) to implement a job queue such as
>> TheSchwartz. I do not want an outside worker, I want my app to be the
>> worker, and let it decide by itself what to do instead of take jobs from=
 a
>> queue.
>>
>
> Yes, you do want an outside worker.  It can be part of  your app, but it
> should be separate from Catalyst.  Put it in a model class.  Ok, sure you
> could have cron run App/script/app_test.pl /path/to/action but why load
> all of Catalyst just to run some code in your application?
>
>
>
>
> --
> Bill Moseley
> moseley at hank.org
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100325/d59d3=
f34/attachment.htm


More information about the Catalyst mailing list