--- loncom/loncron 2004/05/11 19:12:50 1.46
+++ loncom/loncron 2004/05/25 15:20:31 1.51
@@ -1,26 +1,42 @@
#!/usr/bin/perl
-# The LearningOnline Network
-# Housekeeping program, started by cron
+# Housekeeping program, started by cron, loncontrol and loncron.pl
#
-# (TCP networking package
-# 6/1/99,6/2,6/10,6/11,6/12,6/14,6/26,6/28,6/29,6/30,
-# 7/1,7/2,7/9,7/10,7/12 Gerd Kortemeyer)
+# $Id: loncron,v 1.51 2004/05/25 15:20:31 albertel Exp $
+#
+# Copyright Michigan State University Board of Trustees
+#
+# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
+#
+# LON-CAPA is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# LON-CAPA is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with LON-CAPA; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# /home/httpd/html/adm/gpl.txt
+#
+# http://www.lon-capa.org/
#
-# 7/14,7/15,7/19,7/21,7/22,11/18,
-# 2/8 Gerd Kortemeyer
-# 12/23 Gerd Kortemeyer
-# YEAR=2001
-# 09/04,09/06,11/26 Gerd Kortemeyer
$|=1;
+use strict;
use lib '/home/httpd/lib/perl/';
use LONCAPA::Configuration;
use IO::File;
use IO::Socket;
-use strict;
+use HTML::Entities;
+use Getopt::Long;
#globals
use vars qw (%perlvar %simplestatus $errors $warnings $notices $totalcount);
@@ -52,25 +68,33 @@ sub log {
sub errout {
my $fh=shift;
&log($fh,(<
+ Rotating error logs ... ");
+ &log($fh," Seems like it started ... ");
+ &log($fh," Seems like that did not work! ');
printf("%-10s ",$daemon);
if (-e "$perlvar{'lonDaemons'}/logs/$daemon.log"){
open (DFH,"tail -n25 $perlvar{'lonDaemons'}/logs/$daemon.log|");
@@ -101,7 +125,7 @@ sub checkon_daemon {
};
close (DFH);
}
- &log($fh,"
+
ENDERROUT
}
sub start_daemon {
- my ($fh,$daemon,$pidfile) = @_;
+ my ($fh,$daemon,$pidfile,$args) = @_;
my $progname=$daemon;
- if ($daemon eq 'lonc' && $ARGV[0] eq 'new') {
+ if ($daemon eq 'lonc' && $args eq 'new') {
$progname='loncnew';
print "new ";
}
- system("$perlvar{'lonDaemons'}/$progname 2>>$perlvar{'lonDaemons'}/logs/${daemon}_errors");
+ my $error_fname="$perlvar{'lonDaemons'}/logs/${daemon}_errors";
+ my $size=(stat($error_fname))[7];
+ if ($size>40000) {
+ &log($fh,"
Notices $notices Warnings $warnings
- Errors $errors '.$daemon.'
Log
');
+ &log($fh,'
");
+ &log($fh,"'.$daemon.'
Log
"); + &log($fh,"
Give it one more try ...
"); print " "; - if (&start_daemon($fh,$daemon,$pidfile)) { + if (&start_daemon($fh,$daemon,$pidfile,$args)) { &log($fh,""); + &log($fh,"
Unable to start $daemon
"); } } @@ -167,7 +191,7 @@ sub checkon_daemon { if ($line=~/CRITICAL/) { $notices++; } }; close (DFH); - &log($fh,""); + &log($fh,""); } } @@ -179,7 +203,7 @@ sub checkon_daemon { $blksize,$blocks)=stat($fname); if ($size>$maxsize) { - &log($fh,"Rotating logs ..."); + &log($fh,"
Rotating logs ...
"); rename("$fname.2","$fname.3"); rename("$fname.1","$fname.2"); rename("$fname","$fname.1"); @@ -191,7 +215,7 @@ sub checkon_daemon { # --------------------------------------------------------------------- Machine sub log_machine_info { my ($fh)=@_; - &log($fh,'