On Wed, 2002-10-09 at 05:25, Anton Permyakov wrote:
> Hi all,
> 
> I need to start process, which would get big amount of data from another
> server into my DataBase,
> and while it will do it, my browser should show me progress-bar on this data
> extraction.
> 
> I have mod_perl based web-server, so, i should not use fork(), as explained
> in Mod_perl docs. But also i cannot invoke system(), as this proccess could
> take very long time.
> What i have to do?

I needed to do this recently myself.  I am using sessions (under
HTML::Embperl) so I created a temp file and added the name of the temp
file to my session data. 

I 'exec' off the external program after I have printed "waiting" page
content.  I pass the temp file name to the external script so it can
delete it when it is done running. The waiting page includes a meta
refresh, in my case the wait is dynamically determined based on the type
of action taken and the estimated time it will take to produce the
results.

The temp file is deleted once the process was done running. When the
meta refresh occurs it reloads the same page and determines if the temp
file matching the session value still existed and if so redisplays the
appropriate waiting page with a predefined wait time (30 seconds in my
case).  If the temp file is cleared I present the user with the results.

The temp file name should be from a counter file or some form of rand
seed and/or time to avoid duplicate names while processing.  Traffic
will determine how aggressive you need to be in the uniqueness of the
file name.

So in a nutshell

- Create a temp (flag) file
- Generate and send the HTML to the browser which includes a meta
refresh
- Add the temp file to their session data (or something similar)
- Exec a process and send the temp file name to it
- On page refresh look to see if the temp (flag) file still exists and
if so create a new waiting page ( meta refresh ), otherwise deliver end
results.

Aaron Johnson

> 
> May be best solution is using CGI-script, which allows forking without all
> Apache process forking?
> 
> Thank you,
> 
> Best wishes!
> ----------------------------------------------------------------------------
> Anton Permyakov           Web-Developer
> [EMAIL PROTECTED]   WWW.SOLUDIUM.COM
> 
> 

Reply via email to