I'm building a mailing list system in PHP. I have a bunch of PHP stuff that allows me to edit the back-end database (in MySQL for now) through a web interface, but the actual sending needs to be done through an asynchronous, ongoing process outside the web server. I need to be able to start and stop mail-outs through the web interface, meaning that the two environments need to talk to each other somehow. I already have PHP running as mod_php and CLI on OpenBSD 3.1.
What practical things do I need to do?
How should I structure the CLI process code to stay running - do I just wrap it in an infinite loop?
How would I do that and also avoid being a CPU hog (i.e. go slow when there's nothing to do)?
How should I write SIG handlers and the like? Or can PHP handle that for me?
What's the best way of passing data between the two environments?
Does SYSV shared memory work well for IAC between PHP/CLI and mod_php?
Anywhere I might find out more about writing little utility processes
and simple servers in PHP, i.e. not web stuff? PHP for shell/CLI stuff seems to be pretty new and there's not much about that I can find.
Thanks