[LON-CAPA-cvs] cvs: loncom /metadata_database parse_activity_log.pl
matthew
lon-capa-cvs@mail.lon-capa.org
Wed, 22 Dec 2004 14:58:15 -0000
matthew Wed Dec 22 09:58:15 2004 EDT
Modified files:
/loncom/metadata_database parse_activity_log.pl
Log:
More exit codes.
Re-included "use lib '/home/httpd/lib/perl/Apache';" because it doesn't
work without it :(
Index: loncom/metadata_database/parse_activity_log.pl
diff -u loncom/metadata_database/parse_activity_log.pl:1.8 loncom/metadata_database/parse_activity_log.pl:1.9
--- loncom/metadata_database/parse_activity_log.pl:1.8 Mon Dec 20 14:53:36 2004
+++ loncom/metadata_database/parse_activity_log.pl Wed Dec 22 09:58:15 2004
@@ -2,7 +2,7 @@
#
# The LearningOnline Network
#
-# $Id: parse_activity_log.pl,v 1.8 2004/12/20 19:53:36 matthew Exp $
+# $Id: parse_activity_log.pl,v 1.9 2004/12/22 14:58:15 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -34,7 +34,8 @@
# 2 Activity log does not exist
# 3 Unable to connect to database
# 4 Unable to create database tables
-# 5 Unspecified error?
+# 5 Unable to open log file
+# 6 Unable to get lock on activity log
#
#
@@ -50,6 +51,7 @@
use strict;
use DBI;
+use lib '/home/httpd/lib/perl/Apache';
use lib '/home/httpd/lib/perl/';
use LONCAPA::Configuration();
use Apache::lonmysql();
@@ -120,7 +122,8 @@
my $logfile = $perlvar{'lonDaemons'}.'/tmp/parse_activity_log.log.'.time;
print STDERR "$0: logging to $logfile".$/;
if (! open(LOGFILE,">$logfile")) {
- die "Unable to open $logfile for writing. Run aborted.";
+ warn("Unable to open $logfile for writing. Run aborted.");
+ exit 5;
} else {
$logthis = \&log_to_file;
}
@@ -151,7 +154,10 @@
# Wait for a lock on the lockfile to avoid collisions
my $lockfilename = $sourcefilename.'.lock';
open(LOCKFILE,'>'.$lockfilename);
-flock(LOCKFILE,LOCK_EX) || die("Unable to lock $lockfilename. Aborting".$/);
+if (!flock(LOCKFILE,LOCK_EX)) {
+ warn("Unable to lock $lockfilename. Aborting".$/);
+ exit 6;
+}
##
## There will only be a $newfilename file if a copy of this program is already