[LON-CAPA-cvs] cvs: loncom / lond

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 12 Dec 2003 21:37:42 -0000


albertel		Fri Dec 12 16:37:42 2003 EDT

  Modified files:              
    /loncom	lond 
  Log:
  - adding a smattering of status messages to see if I can figure out why lond wedges itself sometimes. (will be  going in 1.1)
  
  
Index: loncom/lond
diff -u loncom/lond:1.164 loncom/lond:1.165
--- loncom/lond:1.164	Tue Dec  2 05:37:59 2003
+++ loncom/lond	Fri Dec 12 16:37:42 2003
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.164 2003/12/02 10:37:59 foxr Exp $
+# $Id: lond,v 1.165 2003/12/12 21:37:42 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -52,7 +52,7 @@
 my $status='';
 my $lastlog='';
 
-my $VERSION='$Revision: 1.164 $'; #' stupid emacs
+my $VERSION='$Revision: 1.165 $'; #' stupid emacs
 my $remoteVERSION;
 my $currenthostid;
 my $currentdomainid;
@@ -513,6 +513,7 @@
     my ($error)=@_;
     $SIG{'QUIT'}='DEFAULT';
     $SIG{__DIE__}='DEFAULT';
+    &status("Catching exception");
     &logthis("<font color=red>CRITICAL: "
      ."ABNORMAL EXIT. Child $$ for server $thisserver died through "
      ."a crash with this error msg->[$error]</font>");
@@ -523,6 +524,7 @@
 }
 
 sub timeout {
+    &status("Handling Timeout");
     &logthis("<font color=ref>CRITICAL: TIME OUT ".$$."</font>");
     &catchexception('Timeout');
 }
@@ -579,6 +581,7 @@
 
 sub REAPER {                        # takes care of dead children
     $SIG{CHLD} = \&REAPER;
+    &status("Handling child death");
     my $pid = wait;
     if (defined($children{$pid})) {
 	&logthis("Child $pid died");
@@ -587,25 +590,30 @@
     } else {
 	&logthis("Unknown Child $pid died");
     }
+    &status("Finished Handling child death");
 }
 
 sub HUNTSMAN {                      # signal handler for SIGINT
+    &status("Killing children (INT)");
     local($SIG{CHLD}) = 'IGNORE';   # we're going to kill our children
     kill 'INT' => keys %children;
     &logthis("Free socket: ".shutdown($server,2)); # free up socket
     my $execdir=$perlvar{'lonDaemons'};
     unlink("$execdir/logs/lond.pid");
     &logthis("<font color=red>CRITICAL: Shutting down</font>");
+    &status("Done killing children");
     exit;                           # clean up with dignity
 }
 
 sub HUPSMAN {                      # signal handler for SIGHUP
     local($SIG{CHLD}) = 'IGNORE';  # we're going to kill our children
+    &status("Killing children for restart (HUP)");
     kill 'INT' => keys %children;
     &logthis("Free socket: ".shutdown($server,2)); # free up socket
     &logthis("<font color=red>CRITICAL: Restarting</font>");
     my $execdir=$perlvar{'lonDaemons'};
     unlink("$execdir/logs/lond.pid");
+    &status("Restarting self (HUP)");
     exec("$execdir/lond");         # here we go again
 }
 
@@ -667,6 +675,7 @@
 #     now be honored.
 #
 sub UpdateHosts {
+    &status("Reload hosts.tab");
     logthis('<font color="blue"> Updating connections </font>');
     #
     #  The %children hash has the set of IP's we currently have children
@@ -691,10 +700,12 @@
 	}
     }
     ReloadApache;
+    &status("Finished reloading hosts.tab");
 }
 
 
 sub checkchildren {
+    &status("Checking on the children (sending signals)");
     &initnewstatus();
     &logstatus();
     &logthis('Going to check on the children');
@@ -709,6 +720,7 @@
     sleep 5;
     $SIG{ALRM} = sub { die "timeout" };
     $SIG{__DIE__} = 'DEFAULT';
+    &status("Checking on the children (waiting for reports)");
     foreach (sort keys %children) {
         unless (-e "$docdir/lon-status/londchld/$_.txt") {
           eval {
@@ -726,6 +738,7 @@
     }
     $SIG{ALRM} = 'DEFAULT';
     $SIG{__DIE__} = \&catchexception;
+    &status("Finished checking children");
 }
 
 # --------------------------------------------------------------------- Logging
@@ -768,17 +781,20 @@
 # ------------------------------------------------------------------ Log status
 
 sub logstatus {
+    &status("Doing logging");
     my $docdir=$perlvar{'lonDocRoot'};
     {
     my $fh=IO::File->new(">>$docdir/lon-status/londstatus.txt");
     print $fh $$."\t".$currenthostid."\t".$status."\t".$lastlog."\n";
     $fh->close();
     }
+    &status("Finished londstatus.txt");
     {
 	my $fh=IO::File->new(">$docdir/lon-status/londchld/$$.txt");
         print $fh $status."\n".$lastlog."\n".time;
         $fh->close();
     }
+    &status("Finished logging");
 }
 
 sub initnewstatus {
@@ -966,8 +982,11 @@
 #   along the connection.
 
 while (1) {
+    &status('Starting accept');
     $client = $server->accept() or next;
+    &status('Accepted '.$client.' off to spawn');
     make_new_child($client);
+    &status('Finished spawning');
 }
 
 sub make_new_child {
@@ -976,6 +995,7 @@
     my $sigset;
 
     $client = shift;
+    &status('Starting new child '.$client);
     &logthis('<font color="green"> Attempting to start child ('.$client.
 	     ")</font>");    
     # block signal for fork