Murcia has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I have a web service (Perl cgi) that needs a lot CPU time. There are three blocks of hard computing. The Web output stops after ending the first block (creating a picture and showing the picture in the browser) without an error.

How can I check where the problem is? Is it the apache server, or perl or system (Linux Suse 9.0)?

Thanks in advance!
Murcia

janitored by ybiC: Retitle from "cgi problem" for better site searching

Replies are listed 'Best First'.
Re: Debug a long-running CGI script?
by ccn (Vicar) on Aug 19, 2004 at 20:04 UTC

    You can trace your program flow, to detect where it stops. You can write to STDERR and then analyse webserver logs. You can write log to a file. You can use very good module Log::Log4perl

Re: Debug a long-running CGI script?
by strat (Canon) on Aug 20, 2004 at 06:17 UTC

    You can also use Devel::DProf to find out in which subroutine the code needs so much time... e.g. write to the header something like

    #! /usr/bin/perl -d:DProf

    then run the script (needs write access to the current directory), and evaluate the trace with dprofpp -T or the like

    Best regards,
    perl -e "s>>*F>e=>y)\*martinF)stronat)=>print,print v8.8.8.32.11.32"

      Thanks, I looked to to apache log file and found a problem with memory "out of memory" and problems with the CGI::Pretty module. I switch to "normal" CGI module and this worked! Thanks all!
Re: Debug a long-running CGI script?
by superfrink (Curate) on Aug 20, 2004 at 00:46 UTC
    I suspect you're trouble could be your browser stops waiting for more data from the server after say 60 seconds. To get around this you might be able to print an HTML comment periodically to the client during your calculations. Of course if the script is calculating to generate an image (like plotting a graph) then you can't. Maybe though you can keep printing out useless header lines until it's ready to print the image. Just a thought. :^\