NYCPHP Meetup

NYPHP.org

[nycphp-talk] background processes (was: building an 1-way email list manager)

csnyder chsnyder at gmail.com
Tue Nov 15 12:04:23 EST 2005


On 11/15/05, Dan Cech <dcech at phpwerx.net> wrote:
> Hans,
>
> I for one would be very interested in a more in-depth discussion on this
> subject, as it sounds like there is a lot more to it than I was aware.
>
> Dan
>
> Hans Zaunere wrote:
>  >
>  > Anthony Papillion wrote on Tuesday, November 15, 2005 4:31 AM:
>  >> This discussion triggers a question that I'm sure someone here can
>  >> answer: wouldn't forking the script to the background allow one to
>  >> send a huge volume of email without a timeout?
>  >
>  > It would, but forking can be a bit of an art.
>  >
>  > For any long running process that you wish to spawn out of PHP
> running under
>  > Apache (as a DSO anyway) you need to cut ties with Apache.

It seems like a much better idea to write the outgoing mail to a queue
or flat file, and then use a separate process in pure PHP to do the
sending. In other words, hand it off to a CLI script.

That CLI script could be a daemon that runs all the time, or (more
simply) it could just be a cron job that starts up and handles the
next item in the queue.

By the way (and please excuse the plug) if you'd like another example
of PHP daemon code that implements signal handling like a real Unix
process, check out simpleDaemon.php from the Pro PHP Security code at
http://apress.com/book/supplementDownload.html?bID=437&sID=2888


--
Chris Snyder
http://chxo.com/


More information about the talk mailing list