--- loncom/Attic/lonc 2001/06/12 15:32:38 1.16
+++ loncom/Attic/lonc 2001/08/30 20:02:28 1.17
@@ -41,7 +41,7 @@ sub catchexception {
die($@);
}
-$childmaxattempts=10;
+$childmaxattempts=5;
# -------------------------------- Set signal handlers to record abnormal exits
@@ -116,7 +116,11 @@ sub REAPER { # ta
sub HUNTSMAN { # signal handler for SIGINT
local($SIG{CHLD}) = 'IGNORE'; # we're going to kill our children
- kill 'INT' => keys %children;
+ map {
+ $wasserver=$children{$_};
+ &logthis('Closing '.$wasserver.': '.&subreply('exit',$wasserver));
+ kill ('INT',$_);
+ } keys %children;
my $execdir=$perlvar{'lonDaemons'};
unlink("$execdir/logs/lonc.pid");
&logthis("CRITICAL: Shutting down");
@@ -125,7 +129,11 @@ sub HUNTSMAN { # si
sub HUPSMAN { # signal handler for SIGHUP
local($SIG{CHLD}) = 'IGNORE'; # we're going to kill our children
- kill 'INT' => keys %children;
+ map {
+ $wasserver=$children{$_};
+ &logthis('Closing '.$wasserver.': '.&subreply('exit',$wasserver));
+ kill ('INT',$_);
+ } keys %children;
&logthis("CRITICAL: Restarting");
unlink("$execdir/logs/lonc.pid");
my $execdir=$perlvar{'lonDaemons'};
@@ -222,7 +230,7 @@ while (1) {
# See who died and start new one
foreach $thisserver (keys %hostip) {
if (!$childpid{$thisserver}) {
- if ($childatt{$thisserver}<=$childmaxattempts) {
+ if ($childatt{$thisserver}<$childmaxattempts) {
$childatt{$thisserver}++;
&logthis(
"INFO: Trying to reconnect for $thisserver "
@@ -287,6 +295,13 @@ print $remotesock "$answer";
$answer=<$remotesock>;
chomp($answer);
&logthis("Init reply for $conserver: >$answer<");
+if ($answer ne 'ok') {
+ my $st=120+int(rand(240));
+ &logthis(
+"WARNING: Init failed $conserver ($st secs)");
+ sleep($st);
+ exit;
+}
sleep 5;
print $remotesock "pong\n";
$answer=<$remotesock>;