[nycphp-talk] building an 1-way email list manager
Hans Zaunere
lists at zaunere.com
Tue Nov 15 17:43:03 EST 2005
Anthony Papillion wrote on Tuesday, November 15, 2005 5:16 PM:
> So then, the ideal way to handle a long running process might be to
> use cron and execute a CLI script, right? Because that would be
> totally independent of the Apache process and is fairly simple (if
> unelegant) to use.
I'm not sure there is a single ideal way - each has it's own advantages and
disadvantages. A long running process - of let's say hours - could be
effectively forked from a mod_php script. But is this a method to create a
true daemon? Not at all - that should be done via CLI/fork.
So there are a number of strategies for solving this type of problem.
-- have a true daemon process sweep a database or filesystem for jobs to run
-- have a true daemon listen for tasks on an internal or external socket
(fun!)
-- have cron start a process that sweeps a database or filesystem (this can
actually get tricky in terms of concurrency; what if a cron fires up a
script that begins to run, but continues to run longer than the next cron
invocation? ie, you need to concurrency control)
-- fork from Apache; this, actually in many ways, is straightforward once
the fork issues are understood
What works best depends on the programmer's skillset (is he a socket guru?
a fork guru?), and of course problems specific to what needs to get done at
the end of the day.
---
Hans Zaunere / President / New York PHP
www.nyphp.org / www.nyphp.com
More information about the talk
mailing list