[Catalyst] [RFC] C::P::Scheduler - cron-like scheduling of events

Andy Grundman andy at hybridized.org
Mon Dec 12 16:21:54 CET 2005


Yuval Kogman wrote:
> On Sun, Dec 11, 2005 at 23:01:24 -0500, Andy Grundman wrote:
> 
>>I have a need for a simple scheduling plugin to do things like clean up database sessions, so I roughed out docs 
>>for a new plugin called Scheduler.  If you've got any thoughts or suggestions, please let me know. :)
> 
> 
> There are a bunch of cron scheduler thingies on the CPAN, i think we
> should use one of them instead of rolling our own.

Certainly for the cron-syntax parsing, I would use DateTime::Event::Cron 
or something similar.  The Schedule::Cron module doesn't really do what 
I want, it's designed to fork processes that sit in a loop waiting for 
the right time.

> Also, how does it get initiated?

Every request the plugin checks if the current time is at or past the 
run time for a scheduled event.  If so, it runs the action/coderef for 
the event and marks it as completed in the state file.

> I was thinking the simplest way to run it is via a cron script, and
> the catalyst scheduler thing just checks if it needed to do
> something between the last invocation and this one.

I think it's nicer to have it built into the app, for cross-platform use 
on Win32 or other places where cron is impossible.  It's also easier to 
access other plugins, models, etc. if run from within the app itself.

>>Depending on the level of traffic to the application, events may or may
>>not run at exactly the correct time, but it should be enough to satisfy many
>>basic scheduling needs.
> 
> 
> This seems to imply that it runs after finalize if needed... How
> does this work with respect to long running jobs?

I'm not sure which stage it will run in, but long-running tasks should 
be avoided, as the docs mention. :)

> I also things that plugins should be able to register for scheduled
> events... For example the session store plugins have a default daily
> run of delete_expired_sessions, but the user can change (or disable)
> this.

This sounds like a cool idea, as long as the user is well aware of it.

-Andy



More information about the Catalyst mailing list