Run a script apart from request
| From: | Brad Fuller | Date: | Mon, 30 Apr 2007 14:55:07 +0000 |
| Subject: | Run a script apart from request | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-254141@lists.php.net to get a copy of this message | ||
Hi all,
I am developing a program that does some intensive data processing, and is
triggered from a page hit and/or a SOAP request.
The processing takes on average 30 seconds to 1 minute, which is OK for a
web page (I can use set_time_limit(0) and just display a pseudo-progress bar
animated gif and a "Please wait..." message) but I can't leave the SOAP
request hanging for that long. I need to send a response immediately.
What I really need to do is acknowledge the client that their request has
been received and will be processed, and terminate that request... and THEN
begin the processing.
One way I thought of doing it would be to put the requests into the database
and run a cron job every X minutes, but I would like to avoid this if at all
possible.
Someone had suggested pcntl_fork() but I'm not sure if that will accomplish
what I need it to... if I fork(), then send a response, kill the parent and
let the child run the process, will the HTTP request wait for the child or
will it die with the parent (like I want it to) ?
Any advice is much appreciated.
Thx,
Brad