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

Hello Folks

I have something very strange happening here. The .fcgi script runs ok - well, almost, some memory leaks I canīt figure out how to solve - but then, after updating the code through ftp, it stops responding, gets stuck and starts returning 500 errors after a long wait. I issue the "top" command at shell, but there isnīt any process for this script anywhere.

Then I go check if it runs in the command line and it does! Smoothly! Only doesnīt at the web!

So, as I have other test script that IS running perfectly from the web without any problems, I just copied the whole content of the running-perfectly-from-the-web script and pasted inside the problematic script, overwriting all its content. Should work, right? It didnīt! So it isnīt the code (wich is below)! It seems Apache is playing arround with me!

What can I do? You guys know what may cause this oddity??

Thanks

Andre

UPDATE: F*, 5 minutes after posting this the fulfilled script started both working and appearing at the "top". This is about 20 minutes after the massive errors, without me having done nothing. How come???

#!/usr/bin/perl -wT # Loads modules use CGI; use CGI::Fast; use DBI; require "./methods.cgi"; use CGI::Carp qw( fatalsToBrowser ); use Time::HiRes qw(gettimeofday); use strict; use lib "/home/myaccount/perl-lib"; $ENV{'PATH'} = "/usr/local/bin:/usr/bin:/bin"; # (to MIME::Lite) # Weīre online? my $online = 1; my $mysqlhost = "mysql.myaccount.com"; if ( $ENV{SERVER_NAME} eq "127.0.0.1" ) { $online = 0; $mysqlhost = "localhost"; } # Connects to mysql [code] # Start of CGI::Fast loop while( my $q = new CGI::Fast ) { # Start cronometer my $elapsed = 0.000; my $t0; my $t1; if ( $online == 1 ) { $t0 = gettimeofday; } # Reading parameters my $cookie = check_string( $q->cookie( -name => "cookie" ) ); my $section = check_string( $q->param("section") ); my $start = check_string( $q->param("start") ); defined $start or $ +start = 1; my $start_mysql = $start - 1; my $rec_p_pag = 30; # Global vars my $now = lc formatdate (time); # Balizamento da aįão, conforme a section solicitada if ( $section eq "this" ) { this(); } else { that(); } # end of chronometer if ( $online == 1 ) { $t1 = gettimeofday; $elapsed = $t1 - $t0; print $elapsed; } sub this { # Query $dbh->do ( ...query ); # Loading hash my %things = load_hash_things(); # starting the html print "Content-type: text/html\n\n"; ...html } ############# # that ############# sub that { ... } } # END OF CGI::FAST LOOP

Replies are listed 'Best First'.
Re: Fcgi script stuck and invisible
by jhourcle (Prior) on Dec 04, 2005 at 13:40 UTC

    From the symptoms that you're describing, I'm guessing that you have your server configured to look for file modifications, and to load the new file when it has changed, rather than requiring a sysadmin to kick the server to look for changes. (I'm not an FCGI user, I use mod_perl, so this may be the defaults under FCGI, for all I know)

    If this is the case, I would advise against FTPing directly over a file. Depending on the time resolution of the engine that tracks file modifications, it may notice that the file has been changed mid-upload, and then not notice that it's been further changed when the upload finishes.

    I typically upload to some alternate location, and then move the files into place. (if you're using FTP, use the 'rename' command)

    I would also suggest looking at your webserver logs, and seeing if there are any more details about the 500s in your error log.