Re: OT: forking so apache won't wait
On Thu, 27 Sep 2001, will trillich wrote:
> debianistas tend to know where to look, so i'm hoping someone
> will point the way--
>
> i know i've run across it before but when i WANT to stub my toe
> on it, it's nowhere to be found: HOW can i have apache/web page
> initiate a process and return quickly to generate a 'processing,
> hold on' page while the process does its processing?
>
> i've got a web page that i launch after ftp-ing a bunch of
> images up to a website. it starts some Image::Magick filters and
> takes a Bloody Good Long Time to complete. i've got mod_perl
> calling the script as an external command (slow, but it keeps
> the ::Magick libraries from sucking up over a meg of apache
> memory) and it forks like this:
Not eaxctly what you asked but you can deiplay a tempoary page while you're
loading.
#!/usr/bin/perl
$|=1;
select (STDOUT);
sub Code($);
## the line below should all be on one line (in case it get wrapped)
print STDOUT "Content-Type: multipart/x-mixed-replace;boundary=TextString\n\n";
for($i=0;$i<=5;$i++) {
print Code($i);
sleep 1;
}
print Code("All Done");
print STDOUT "--TextString--\n";
sub Code($) {
$msg=shift;
return <<"DONE";
--TextString
Content-Type: text/html
<body>
<Pre>
$msg
</Pre>
</body>
DONE
}
You can see the output of this at:
http://thor.cantech.net.au/~tony/Misc-cgi/count.cgi
You could easily use this redraw, the screen after rendering X images.
HTH.
Yours Tony.
/*
* "The significant problems we face cannot be solved at the
* same level of thinking we were at when we created them."
* --Albert Einstein
*/
Reply to: