--- loncom/metadata_database/parse_activity_log.pl 2004/12/20 19:53:36 1.8 +++ loncom/metadata_database/parse_activity_log.pl 2004/12/22 14:58:15 1.9 @@ -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 @@ if ($log) { 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 @@ $logthis->('Beginning logging '.time); # 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