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

Adam Herzog adam at herzogdesigns.com
Tue Dec 13 05:39:38 CET 2005


>> 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.

Perfect; I'd be able to programatically make changes, and the plugin 
would autoreload when the file has changed. Likewise, I think other 
users would appreciate being able to keep their schedule separate from 
their code. I guess there'd be a config option to specify the yml file.

I wonder if the stat call to the YAML on every request would become too 
expensive... maybe you could provide either a) an option to set how 
often to check (a built in schedule, I suppose), or b) the ability to 
programatically force a reload.

>> 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.
>
> http://www.myapp.com/?schedule_trigger=send_all_email

Oh. I don't think that's quite what I meant. Or, I misunderstand what 
you're saying. I want to stay away from choosing the exact task in the 
request. Although I think somebody else requested the ability to 
trigger like that, I was thinking of letting the plugin operate as 
originally described: run an event at the first request after the given 
time. But, only if that request is to a certain path (or with a certain 
param.)

So, for instance, I would specify in the YAML what the schedule is for 
each of my events, but the scheduler would only operate if the request 
was:

http://www.myapp.com/?run_scheduler=1

In that way, I could still use the YAML to specify what the schedule 
would be (I'd use increments of 30 minutes), and then have the cron 
wget that url every half an hour.

The other possibility, is to have the scheduler check on every request, 
as you originally described, but only if the client is localhost (or 
whatever.) I'm think the param method is probably a better bet.

So, I guess I'd like to see schedule() take 'at', 'event', and 
'auto_run'. auto_run being a boolean that specifies whether that event 
is run on every event, or only when the specified param 
(?run_schedule=1) is entered. Of course, then we get back into the 
issue of security, I suppose. Hrm. So... I guess there would have to be 
something like

__PACKAGE__->config->{scheduler}->{hosts_allow} = [ '127.0.0.1', 
'oth.er.i.p' ];

which would apply to any non-auto-run events.

Thoughts?

-A




More information about the Catalyst mailing list