--- loncom/loncron 2000/06/27 19:21:22 1.5 +++ loncom/loncron 2000/12/08 22:08:57 1.8 @@ -204,7 +204,7 @@ print $fh ""; # ------------------------------------------------------------------------ lonsql -if ($perlvar{'lonRole'} eq "library") { +if ($perlvar{'lonRole'} eq "library" && 1==0) { print $fh '

lonsql

Log

';
     
@@ -303,17 +303,38 @@ print $fh "
"; my $londfile="$perlvar{'lonDaemons'}/logs/lond.pid"; -if (-e $londfile) { +my $restartflag=1; +if (-e $londfile) { my $lfh=IO::File->new("$londfile"); my $londpid=<$lfh>; chomp($londpid); if (kill 0 => $londpid) { print $fh "

lond at pid $londpid responding

"; + $restartflag=0; } else { - $errors++; $errors++; + $errors++; print $fh "

lond at pid $londpid not responding

"; + # Intelligently handle this. + # Possibility #1: there is no process + # Solution: remove .pid file and restart + if (getpgrp($londpid)==-1) { + unlink($londfile); + $restartflag=1; + } + else { + # Possibility #2: there is a zombie process + # Possibility #3: there is a live process that is not responding + # for an unknown reason + # Solution: kill process, remove .pid and restart + kill 2 => $londpid; + unlink($londfile); + $restartflag=1; + } + print $fh + "

Deciding to clean up stale .pid file and restart lond

"; } -} else { +} +if ($restartflag==1) { $errors++; print $fh "

lond not running, trying to start

"; system("$perlvar{'lonDaemons'}/lond"); @@ -383,6 +404,7 @@ print $fh ""; my $loncfile="$perlvar{'lonDaemons'}/logs/lonc.pid"; +$restartflag=1; if (-e $loncfile) { my $lfh=IO::File->new("$loncfile"); my $loncpid=<$lfh>; @@ -390,11 +412,31 @@ if (-e $loncfile) { if (kill 0 => $loncpid) { print $fh "

lonc at pid $loncpid responding, sending USR1

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

lonc at pid $loncpid not responding

"; + # Intelligently handle this. + # Possibility #1: there is no process + # Solution: remove .pid file and restart + if (getpgrp($loncpid)==-1) { + unlink($loncfile); + $restartflag=1; + } + else { + # Possibility #2: there is a zombie process + # Possibility #3: there is a live process that is not responding + # for an unknown reason + # Solution: kill process, remove .pid and restart + kill 2 => $loncpid; + unlink($loncfile); + $restartflag=1; + } + print $fh + "

Deciding to clean up stale .pid file and restart lonc

"; } -} else { +} +if ($restartflag==1) { $errors++; print $fh "

lonc not running, trying to start

"; system("$perlvar{'lonDaemons'}/lonc");