Looking for directions : spawning independent CGIs 
Author Message
 Looking for directions : spawning independent CGIs

Hi,

just a quick summary of my problem. Maybe somebody here can point me in the
right direction:
I want to do some database administration using a web-interface.
Once the file is uploaded the Perl script has a lot of work to do. Because
the browser doesn't wait long enough for the script to finish, but rather
reports a server error (after approx. 5 min) I would like to seperate the
tasks from one another.
My Idea was to spawn a child process and keep the browser busy reloading a
dynamically created html-page. Unfortunately it seems that it's not possible
since the execution of the perl script is bound to the http-server-user and
process.

Any ideas?

Regards,

Ole.



Tue, 26 Apr 2005 15:12:56 GMT  
 Looking for directions : spawning independent CGIs
On Nov 8, Ole Voss inscribed on the eternal scroll:

Quote:
> I want to do some database administration using a web-interface.
> Once the file is uploaded the Perl script has a lot of work to do. Because
> the browser doesn't wait long enough for the script to finish, but rather
> reports a server error (after approx. 5 min) I would like to seperate the
> tasks from one another.

Standard CGI FAQ, but nothing specific to Perl.

E.g http://www.htmlhelp.com/faq/cgifaq.3.html#8

(note that the immediately following FAQ isn't really the answer to
your question, since you don't need to interact continuously with the
long-running process).

Quote:
> My Idea was to spawn a child process and keep the browser busy reloading a
> dynamically created html-page.

You want that the user should do nothing else in their browser window
for > 5 minutes waiting for a response to say the process is complete?
That might not be optimal...?

Quote:
> Unfortunately it seems that it's not possible
> since the execution of the perl script is bound to the http-server-user and
> process.

Not quite sure which part of the problem you're referring to here.
Launching the job (in a way that avoids it getting killed by the web
server) is what the above FAQ addresses.  Keep in mind that the CGI
script model is for the client to invoke a URL, which causes the
server to do a modest amount of processing without undue delay, return
an answer, and that's the end of that particular HTTP transaction.

If that was only the launching of a long-running process, then you may
want some way to visit later and review the progress of the request,
which I presume is the point of your question.

Since HTTP itself is stateless. that needs some way of "maintaining
state", for which there are plenty of tutorials.

Alternatively the invoker could identify themselves by email address,
and the long-running process could announce completion by emailing the
results.  (Please implement this in a way that avoids it being misused
as an open spam-relay.)

Quote:
> Any ideas?

Read FAQs, and pitch your questions, on the more-appropriate group[1],
by reference to a specific FAQ that you haven't understood.  Usually
brings better results.

[1]comp.infosystems.www.authoring.cgi - read its posting guidelines



Tue, 26 Apr 2005 16:45:44 GMT  
 Looking for directions : spawning independent CGIs

Quote:

> My Idea was to spawn a child process and keep the browser busy reloading a
> dynamically created html-page. Unfortunately it seems that it's not possible
> since the execution of the perl script is bound to the http-server-user and
> process.

Cut the ties that bind!  (i.e. the close or repopen the STD*
file handles).

Quote:
> Any ideas?

BTW: This has nothing to do with Perl - you'd do the same in a CGI
written in any language.

BTW: This is in the Perl FAQ nonetheless - but it's not easy to find
because it appears as "How do I fork a daemon process?"

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Tue, 26 Apr 2005 18:03:03 GMT  
 Looking for directions : spawning independent CGIs


Quote:
> Because the browser doesn't wait long enough for the script to finish,
> but rather reports a server error (after approx. 5 min) I would like
> to seperate the tasks from one another.

It WILL however wait, if you forcibly keep the connection up. Why not send
a HTML comment every now and then during the process?

Anyways... the other answers I've seen so far should provide what you are
looking for.

You might want to consider following up to another newsgroup though. :-)



Tue, 26 Apr 2005 19:19:29 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Newbie looking for direction

2. Looking for the right direction

3. Looking for direction

4. spawning an xterm and then spawning a second program within

5. Spawning asynchronously on NT 4.0: Win32::Spawn()?

6. Position Independent Perl

7. byte-order independent MLDBM database

8. platform-independent rand?

9. vector graphics format-independent module

10. Developing Platform-Independent Code - How to ??????????

11. platform independent way to get SCSI tape status

12. Platform independent GUI with Perl

 

 
Powered by phpBB® Forum Software