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

Andy Grundman andy at hybridized.org
Tue Dec 13 03:55:35 CET 2005

Adam Herzog wrote:
> I have an app that I'm working on for a customer which has a handful of 
> different cron-type tasks that need to be performed: email reports, 
> clear old db data, remove old thumbnails, create new ones, etc, etc. The 
> app is for a specific customer, but they'd eventually like to be able to 
> distribute it to other organizations easily.

Cool, sounds like a perfect use for this plugin.

> In an effort to allow flexibility without complication, I'd been 
> thinking (until this thread started) that what I was going to write a 
> quick interface which would allow the administrator to choose which 
> time(s)/how often each task would run, and I'd store that in a file or 
> db somewhere. Then, there would be a cron which wget'd 
> http://www.myapp.com/admin/cron (or something like that) every 30 
> minutes or so, and the app would manage executing the individual tasks 
> if necessary. That would also let me log in the database the success or 
> failure of the tasks, and the user can easily adjust the schedule of 
> events (since they generally aren't familiar with cron, or anything unix 
> related.)
> I guess that was a lot of background to basically ask this:
> This plugin would definitely help with that, provided that I could 
> access the schedule (to display it to the user) and change the schedule 
> without having to restart the app.

I think this should be possible.  All schedule data could be stored in a YAML 
file and reloaded when changed.

>> Events which consume a lot of time will slow the request processing 
>> for the
>> user who triggers the event.  Long-running tasks should not be 
>> scheduled using
>> this plugin.
> In regards to this, is the only problem that the request will take a 
> long time? Some of the events may be long running, but if it was 
> executed on the requests from the system cron, then I don't care. So, 
> would/could it be possible to have the scheduler only run if a specific 
> controller or path were requested? Or, perhaps, only for requests from a 
> certain IP (ie localhost)...

Yeah this is workable.  The plugin can support 2 kinds of events: those that run 
automatically at certain intervals and those that must be run manually.  And 
your IP restriction idea would work for manually allowing events to be run.

I think the easiest way to do this would be to use the "trigger" idea mentioned 
earlier, and not directly call the method, but use a param to trigger the event.


The other option is to use a custom attribute for methods that perform scheduled 
events, but I think that's a lot more work to implement, and would not allow 
coderefs to be run this way.



More information about the Catalyst mailing list