--- loncom/loncron 2000/10/26 22:21:02 1.6
+++ loncom/loncron 2000/12/06 21:11:35 1.7
@@ -303,17 +303,35 @@ 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++;
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;
+ }
+ # 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 +401,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 +409,28 @@ if (-e $loncfile) {
if (kill 0 => $loncpid) {
print $fh "lonc at pid $loncpid responding, sending USR1
";
kill USR1 => $loncpid;
+ $restartflag=0;
} else {
$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;
+ }
+ # 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");