Re: Forking and BG processes in PHP
| From: | Shane Wright | Date: | Tue, 06 Nov 2001 10:34:02 +0000 |
| Subject: | Re: Forking and BG processes in PHP | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73567@lists.php.net to get a copy of this message | ||
Hi
There are [messy] ways of doing it like this, but I find the tidiest approach
is to add an entry to a queue table in the database and have a background
process running every minute or so that checks the queue and runs any new
jobs.
This keeps the web interface [very] nippy and lets jobs of any size get done
btw- you'll probs find it useful to limit it to one background job at a time.
--
Shane
On Tuesday 06 November 2001 10:15 am, Massimiliano Bariola wrote:
> Hi everybody,
>
> I wasn't able to find a good answer in the archives, so I thought I
> would ask here.
>
> This is the scenario: An user can request a time-expensive DB
> processing via a PHP page. I'd like to arrange for having a
> confirmation page telling the user that the request is being
> processed, and then redirecting him/doing whatever else/etc.
> Meanwhile, there should be a process actually doing the DB work.
> When it's finished, it should send a mail to the requester including
> an URL for the download of the results of the operation.
>
> Problem is, is there a way to make PHP start a background process
> which is independent from the spawning page time-line?
>
> the closest I've seen to this is the use of
> register/unregister_tick_function but it isn't clear from
> documentation as to whether the main flow of execution is suspended at
> the time of execution of the tick_function (i.e. working like a
> GOTO/GOSUB) or it's actually spawning a new process with a different
> timeline (thus allowing the main page to finish without killing the
> tick_function as well)
>
> Or... do I need to forget about it and call bash scripts?
>
> thanks for your answers,
>
> Max