--- loncom/loncron 2002/09/09 13:59:16 1.33 +++ loncom/loncron 2002/10/29 20:21:32 1.34 @@ -154,6 +154,7 @@ print $fh (<lonsql
  • lond
  • lonc +
  • lonhttpd
  • lonnet
  • Connections
  • Delayed Messages @@ -595,6 +596,103 @@ $fname="$perlvar{'lonDaemons'}/logs/lonc my ($dev,$ino,$mode,$nlink, $uid,$gid,$rdev,$size, + $atime,$mtime,$ctime, + $blksize,$blocks)=stat($fname); + +if ($size>40000) { + print $fh "Rotating logs ...

    "; + rename("$fname.2","$fname.3"); + rename("$fname.1","$fname.2"); + rename("$fname","$fname.1"); +} + + +&errout($fh); +# -------------------------------------------------------------------- lonhttpd + +print $fh '


    lonhttpd

    Log

    ';
    +print "lonhttpd\n";
    +
    +if (-e "$perlvar{'lonDaemons'}/logs/lonhttpd.log"){
    +open (DFH,"tail -n25 $perlvar{'lonDaemons'}/logs/lonhttpd.log|");
    +while ($line=) { 
    +   print $fh "$line";
    +   if ($line=~/INFO/) { $notices++; }
    +   if ($line=~/WARNING/) { $notices++; }
    +   if ($line=~/CRITICAL/) { $warnings++; }
    +};
    +close (DFH);
    +}
    +print $fh "
    "; + +my $lonhttpdfile="$perlvar{'lonDaemons'}/logs/lonhttpd.pid"; + +$restartflag=1; +if (-e $lonhttpdfile) { + my $lfh=IO::File->new("$lonhttpdfile"); + my $lonhttpdpid=<$lfh>; + chomp($lonhttpdpid); + if (kill 0 => $lonhttpdpid) { + print $fh "

    lonhttpd at pid $lonhttpdpid responding, sending USR1

    "; + kill USR1 => $lonhttpdpid; + $restartflag=0; + } else { + $errors++; + print $fh "

    lonhttpd at pid $lonhttpdpid not responding

    "; + # Solution: kill parent and children processes, remove .pid and restart + $restartflag=1; + print $fh + "

    Decided to clean up stale .pid file and restart lonhttpd

    "; + } +} +if ($restartflag==1) { + $errors++; + print $fh '
    Killall lonhttpd: '. + system('killall lonhttpd').' - '; + sleep 2; + print $fh unlink($lonhttpdfile).' - '.system('killall -9 lonhttpd'). + '
    '; + print $fh "

    lonhttpd not running, trying to start

    "; + system( + "$perlvar{'lonDaemons'}/lonhttpd 2>>$perlvar{'lonDaemons'}/logs/lonhttpd_errors"); + sleep 2; + if (-e $lonhttpdfile) { + print $fh "Seems like it started ...

    "; + my $lfh=IO::File->new("$lonhttpdfile"); + my $lonhttpdpid=<$lfh>; + chomp($lonhttpdpid); + sleep 2; + if (kill 0 => $lonhttpdpid) { + print $fh "

    lonhttpd at pid $lonhttpdpid responding

    "; + } else { + $errors++; $errors++; + print $fh "

    lonhttpd at pid $lonhttpdpid not responding

    "; + print $fh "Give it one more try ...

    "; + system( + "$perlvar{'lonDaemons'}/lonhttpd 2>>$perlvar{'lonDaemons'}/logs/lonhttpd_errors"); + sleep 2; + } + } else { + print $fh "Seems like that did not work!

    "; + $errors++; + } + if (-e "$perlvar{'lonDaemons'}/logs/lonhttpd.log") { + print $fh "

    ";
    +    open (DFH,"tail -n100 $perlvar{'lonDaemons'}/logs/lonhttpd.log|");
    +    while ($line=) { 
    +      print $fh "$line";
    +      if ($line=~/WARNING/) { $notices++; }
    +      if ($line=~/CRITICAL/) { $notices++; }
    +    };
    +    close (DFH);
    +    print $fh "
    "; + } +} + +$fname="$perlvar{'lonDaemons'}/logs/lonhttpd.log"; + + my ($dev,$ino,$mode,$nlink, + $uid,$gid,$rdev,$size, $atime,$mtime,$ctime, $blksize,$blocks)=stat($fname);