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

Andy Grundman andy at hybridized.org
Wed Dec 14 20:51:16 CET 2005


Brandon Black wrote:
> Running cron jobs from within mod_perl, for instance, is problematic
> because it has to check for times during finalize() or some other
> request-initiated thing, and if the cron-task in question does in fact
> have a long run-time, that's bad.  If I were to schedule a cronjob for
> 4:00AM, and on a particular night nobody used my application from
> 3-7AM, the job would likely get run at 7AM.  And if that task took an
> hour to complete, at the very least a mod_perl child is tied up for an
> hour.  I would imagine under some Engines it could turn into a much
> worse thing.

Yeah, that would indeed suck.  I bet you could actually fire up a 
server.pl version of your app for the sole purpose of running cron jobs 
with.  Then you're not using mod_perl's instance for long-running tasks.

> I could set up a real cron job to hit the front page of my webserver
> once an hour just to kick the Cat app in the head and make sure the
> cat-cron jobs get run, but then I've gone and used the system's cron
> anyways, so why bother?

Sure, but it is not as easy to write a standalone script that can make 
use of other Cat plugins, models, etc.  Using the Scheduler plugin, you 
can easily do that.

> A potential solution would be to make a seperate perl-based generic
> cron daemon which can run independant of the Catalyst Engine from
> scripts/ (let's call it catcron.pl), and have the Engine or something
> else early in the startup process decide when and how to fire it up
> and shut it down (fork/exec it on startup before children are spawned,
> send it a kill signal on shutdown).  The ->config() or ->schedule()
> data that's available statically at App start time could be written to
> a crontab file that catcron.pl reads on startup.

I think you'd run into cross-platform issues with this, especially on 
Windows.  If you manually started a server.pl version of the app like I 
mentioned above, and used a non-auto-running event, it might work just 
as good.

-Andy



More information about the Catalyst mailing list