Diff for /loncom/Attic/lonc between versions 1.15 and 1.17

version 1.15, 2001/03/15 20:25:20 version 1.17, 2001/08/30 20:02:28
Line 16 Line 16
 # 12/05 Scott Harrison  # 12/05 Scott Harrison
 # 12/05 Gerd Kortemeyer  # 12/05 Gerd Kortemeyer
 # 01/10/01 Scott Harrison  # 01/10/01 Scott Harrison
 # 03/14/01,03/15 Gerd Kortemeyer  # 03/14/01,03/15,06/12 Gerd Kortemeyer
 #   # 
 # based on nonforker from Perl Cookbook  # based on nonforker from Perl Cookbook
 # - server who multiplexes without forking  # - server who multiplexes without forking
Line 41  sub catchexception { Line 41  sub catchexception {
     die($@);      die($@);
 }  }
   
 $childmaxattempts=10;  $childmaxattempts=5;
   
 # -------------------------------- Set signal handlers to record abnormal exits  # -------------------------------- Set signal handlers to record abnormal exits
   
Line 116  sub REAPER {                        # ta Line 116  sub REAPER {                        # ta
   
 sub HUNTSMAN {                      # signal handler for SIGINT  sub HUNTSMAN {                      # signal handler for SIGINT
     local($SIG{CHLD}) = 'IGNORE';   # we're going to kill our children      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'};      my $execdir=$perlvar{'lonDaemons'};
     unlink("$execdir/logs/lonc.pid");      unlink("$execdir/logs/lonc.pid");
     &logthis("<font color=red>CRITICAL: Shutting down</font>");      &logthis("<font color=red>CRITICAL: Shutting down</font>");
Line 125  sub HUNTSMAN {                      # si Line 129  sub HUNTSMAN {                      # si
   
 sub HUPSMAN {                      # signal handler for SIGHUP  sub HUPSMAN {                      # signal handler for SIGHUP
     local($SIG{CHLD}) = 'IGNORE';  # we're going to kill our children      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("<font color=red>CRITICAL: Restarting</font>");      &logthis("<font color=red>CRITICAL: Restarting</font>");
     unlink("$execdir/logs/lonc.pid");      unlink("$execdir/logs/lonc.pid");
     my $execdir=$perlvar{'lonDaemons'};      my $execdir=$perlvar{'lonDaemons'};
Line 222  while (1) { Line 230  while (1) {
                                     # See who died and start new one                                      # See who died and start new one
     foreach $thisserver (keys %hostip) {      foreach $thisserver (keys %hostip) {
         if (!$childpid{$thisserver}) {          if (!$childpid{$thisserver}) {
     if ($childatt{$thisserver}<=$childmaxattempts) {      if ($childatt{$thisserver}<$childmaxattempts) {
        $childatt{$thisserver}++;         $childatt{$thisserver}++;
                &logthis(                 &logthis(
    "<font color=yellow>INFO: Trying to reconnect for $thisserver "     "<font color=yellow>INFO: Trying to reconnect for $thisserver "
Line 287  print $remotesock "$answer"; Line 295  print $remotesock "$answer";
 $answer=<$remotesock>;  $answer=<$remotesock>;
 chomp($answer);  chomp($answer);
 &logthis("Init reply for $conserver: >$answer<");  &logthis("Init reply for $conserver: >$answer<");
   if ($answer ne 'ok') {
          my $st=120+int(rand(240));
          &logthis(
   "<font color=blue>WARNING: Init failed $conserver ($st secs)</font>");
          sleep($st);
          exit; 
   }
 sleep 5;  sleep 5;
 print $remotesock "pong\n";  print $remotesock "pong\n";
 $answer=<$remotesock>;  $answer=<$remotesock>;
Line 394  while (1) { Line 409  while (1) {
     # check for new information on the connections we have      # check for new information on the connections we have
   
     # anything to read or accept?      # anything to read or accept?
     foreach $client ($select->can_read(1)) {      foreach $client ($select->can_read(0.1)) {
   
         if ($client == $server) {          if ($client == $server) {
             # accept a new connection              # accept a new connection

Removed from v.1.15  
changed lines
  Added in v.1.17


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>