[LON-CAPA-cvs] cvs: loncom / loncron
raeburn
raeburn@source.lon-capa.org
Fri, 03 Jun 2011 20:45:11 -0000
raeburn Fri Jun 3 20:45:11 2011 EDT
Modified files:
/loncom loncron
Log:
- Include timeouts within &write_loncaparevs() and &write_serverhomeIDs()
so script is not tied up by unresponsive hosts.
Index: loncom/loncron
diff -u loncom/loncron:1.89 loncom/loncron:1.90
--- loncom/loncron:1.89 Sat May 14 16:12:53 2011
+++ loncom/loncron Fri Jun 3 20:45:10 2011
@@ -2,7 +2,7 @@
# Housekeeping program, started by cron, loncontrol and loncron.pl
#
-# $Id: loncron,v 1.89 2011/05/14 16:12:53 raeburn Exp $
+# $Id: loncron,v 1.90 2011/06/03 20:45:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -687,11 +687,22 @@
}
sub write_loncaparevs {
+ print "Retrieving LON-CAPA version information\n";
if (open(my $fh,">$perlvar{'lonTabDir'}/loncaparevs.tab")) {
my %hostname = &Apache::lonnet::all_hostnames();
foreach my $id (sort(keys(%hostname))) {
if ($id ne '') {
- my $loncaparev = &Apache::lonnet::get_server_loncaparev('',$id,1,'loncron');
+ my $loncaparev;
+ eval {
+ local $SIG{ ALRM } = sub { die "TIMEOUT" };
+ alarm(10);
+ $loncaparev =
+ &Apache::lonnet::get_server_loncaparev('',$id,1,'loncron');
+ alarm(0);
+ };
+ if ($@ && $@ =~ m/TIMEOUT/) {
+ print "time out while contacting lonHost: $id for version\n";
+ }
if ($loncaparev =~ /^[\w.\-]+$/) {
print $fh $id.':'.$loncaparev."\n";
}
@@ -703,12 +714,23 @@
}
sub write_serverhomeIDs {
+ print "Retrieving LON-CAPA lonHostID information\n";
if (open(my $fh,">$perlvar{'lonTabDir'}/serverhomeIDs.tab")) {
my %name_to_host = &Apache::lonnet::all_names();
foreach my $name (sort(keys(%name_to_host))) {
if ($name ne '') {
if (ref($name_to_host{$name}) eq 'ARRAY') {
- my $serverhomeID = &Apache::lonnet::get_server_homeID($name,1,'loncron');
+ my $serverhomeID;
+ eval {
+ local $SIG{ ALRM } = sub { die "TIMEOUT" };
+ alarm(10);
+ $serverhomeID =
+ &Apache::lonnet::get_server_homeID($name,1,'loncron');
+ alarm(0);
+ };
+ if ($@ && $@ =~ m/TIMEOUT/) {
+ print "Time out while contacting server: $name\n";
+ }
if ($serverhomeID ne '') {
print $fh $name.':'.$serverhomeID."\n";
} else {