version 1.23, 2003/09/15 09:24:49
|
version 1.26, 2003/09/30 11:11:17
|
Line 45
|
Line 45
|
|
|
# Change log: |
# Change log: |
# $Log$ |
# $Log$ |
|
# Revision 1.26 2003/09/30 11:11:17 foxr |
|
# Add book-keeping hashes to support the re-init procedure. |
|
# |
|
# Revision 1.25 2003/09/23 11:22:14 foxr |
|
# Tested ability to receive sigusr2 This is now logged and must be |
|
# properly implemented as a re-read of hosts and re-init of appropriate |
|
# children. |
|
# |
|
# Revision 1.24 2003/09/16 09:46:42 foxr |
|
# Added skeletal infrastructure to support SIGUSR2 update hosts request. |
|
# |
# Revision 1.23 2003/09/15 09:24:49 foxr |
# Revision 1.23 2003/09/15 09:24:49 foxr |
# Add use strict and fix all the fallout from that. |
# Add use strict and fix all the fallout from that. |
# |
# |
Line 141 use LONCAPA::HashIterator;
|
Line 152 use LONCAPA::HashIterator;
|
# |
# |
# Disable all signals we might receive from outside for now. |
# Disable all signals we might receive from outside for now. |
# |
# |
#$SIG{QUIT} = IGNORE; |
|
#$SIG{HUP} = IGNORE; |
|
#$SIG{USR1} = IGNORE; |
|
#$SIG{INT} = IGNORE; |
|
#$SIG{CHLD} = IGNORE; |
|
#$SIG{__DIE__} = IGNORE; |
|
|
|
|
|
# Read the httpd configuration file to get perl variables |
# Read the httpd configuration file to get perl variables |
Line 159 my %perlvar = %{$perlvarref};
|
Line 164 my %perlvar = %{$perlvarref};
|
# parent and shared variables. |
# parent and shared variables. |
|
|
my %ChildHash; # by pid -> host. |
my %ChildHash; # by pid -> host. |
|
my %HostToPid; # By host -> pid. |
|
my %HostHash; # by loncapaname -> IP. |
|
|
|
|
my $MaxConnectionCount = 10; # Will get from config later. |
my $MaxConnectionCount = 10; # Will get from config later. |
Line 1518 sub CreateChild {
|
Line 1525 sub CreateChild {
|
if($pid) { # Parent |
if($pid) { # Parent |
$RemoteHost = "Parent"; |
$RemoteHost = "Parent"; |
$ChildHash{$pid} = $RemoteHost; |
$ChildHash{$pid} = $RemoteHost; |
|
$HostToPid{$host}= $pid; |
sigprocmask(SIG_UNBLOCK, $sigset); |
sigprocmask(SIG_UNBLOCK, $sigset); |
|
|
} else { # child. |
} else { # child. |
Line 1580 while (! $HostIterator->end()) {
|
Line 1588 while (! $HostIterator->end()) {
|
|
|
my $hostentryref = $HostIterator->get(); |
my $hostentryref = $HostIterator->get(); |
CreateChild($hostentryref->[0]); |
CreateChild($hostentryref->[0]); |
|
$HostHash{$hostentryref->[0]} = $hostentryref->[4]; |
$HostIterator->next(); |
$HostIterator->next(); |
} |
} |
$RemoteHost = "Parent Server"; |
$RemoteHost = "Parent Server"; |
Line 1596 $SIG{INT} = \&Terminate;
|
Line 1605 $SIG{INT} = \&Terminate;
|
$SIG{TERM} = \&Terminate; |
$SIG{TERM} = \&Terminate; |
$SIG{HUP} = \&Restart; |
$SIG{HUP} = \&Restart; |
$SIG{USR1} = \&CheckKids; |
$SIG{USR1} = \&CheckKids; |
|
$SIG{USR2} = \&UpdateKids; # LonManage update request. |
|
|
while(1) { |
while(1) { |
my $deadchild = wait(); |
my $deadchild = wait(); |
if(exists $ChildHash{$deadchild}) { # need to restart. |
if(exists $ChildHash{$deadchild}) { # need to restart. |
my $deadhost = $ChildHash{$deadchild}; |
my $deadhost = $ChildHash{$deadchild}; |
|
delete($HostToPid{$deadhost}); |
delete($ChildHash{$deadchild}); |
delete($ChildHash{$deadchild}); |
Log("WARNING","Lost child pid= ".$deadchild. |
Log("WARNING","Lost child pid= ".$deadchild. |
"Connected to host ".$deadhost); |
"Connected to host ".$deadhost); |
Line 1639 sub CheckKids {
|
Line 1650 sub CheckKids {
|
|
|
=pod |
=pod |
|
|
|
=head1 UpdateKids |
|
|
|
parent's SIGUSR2 handler. This handler: |
|
|
|
=item |
|
|
|
Rereads the hosts file. |
|
|
|
=item |
|
|
|
Kills off (via sigint) children for hosts that have disappeared. |
|
|
|
=item |
|
|
|
HUP's children for hosts that already exist (this just forces a status display |
|
and resets the connection retry count for that host. |
|
|
|
=item |
|
|
|
Starts new children for hosts that have been added to the hosts.tab file since |
|
the start of the master program and maintains them. |
|
|
|
=cut |
|
|
|
sub UpdateKids { |
|
Log("INFO", "Updating connections via SIGUSR2"); |
|
} |
|
|
|
|
|
=pod |
|
|
=head1 Restart |
=head1 Restart |
|
|
Signal handler for HUP... all children are killed and |
Signal handler for HUP... all children are killed and |