Changeset 40


Ignore:
Timestamp:
Dec 5, 2011, 11:19:27 AM (12 years ago)
Author:
g7moreau
Message:
  • Small bug in logfile implementation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oarutils/oar-parexec

    r39 r40  
    4343my $log_h = IO::File->new();
    4444if (-e $logfile) {
    45         $log_h->open("< $logfile")
    46          or die "can't read log file: $!";
     45   $log_h->open("< $logfile")
     46      or die "can't read log file: $!";
    4747   while (<$log_h>) {
    48                 $state{$1} = 'start' if m/^start\sjob\s(\d+)/;
    49                 $state{$1} = 'end'   if m/^end\sjob\s(\d+)/;
     48                $state{$1} = 'start' if m/^start\s+job\s+(\d+)\s/;
     49                $state{$1} = 'end'   if m/^end\s+job\s+(\d+)\s/;
    5050           }
    5151   $log_h->close();
     
    5353if ($logfile) {
    5454   $log_h->open(">> $logfile")
    55          or die "can't open log file: $!";
     55         or die "can't append log file $logfile: $!";
     56   $log_h->autoflush;
    5657   $log_h = unblock $log_h;
    5758   }
    5859
    5960my @job = ();
    60 open( JOB_LIST, '<', "$file" ) or die "can't open $file: $!";
     61open( JOB_LIST, '<', "$file" ) or die "can't open job file $file: $!";
    6162while (<JOB_LIST>) {
    6263   chomp;
     
    110111   for my $job (@job) {
    111112      $job_num++;
    112                 if (exists $state{$job_num} and $state{$job_num} eq 'end') {
    113                         delete $state{$job_num};
    114                         cede;
    115                         next;
    116                    }
    117                 if (exists $state{$job_num} and $state{$job_num} eq 'start') {
    118                         print "warning: job $job_num was not finished, relaunching...\n" if $verbose;
    119                    }           
     113
     114      if (exists $state{$job_num}) {
     115         if ($state{$job_num} eq 'start') {
     116            print "warning: job $job_num was not finished, relaunching...\n" if $verbose;
     117            }
     118         elsif ($state{$job_num} eq 'end') {
     119            delete $state{$job_num};
     120            $job_todo->down;
     121            print "warning: job $job_num already done\n" if $verbose;
     122            cede;
     123            next;
     124            }
     125         }             
    120126
    121127      my $job_ressource = $ressources->get;
    122128
    123                 last if $oar_checkpoint->count > 0;
     129      last if $oar_checkpoint->count() > 0;
    124130
    125131      my ($node_connect) = split ',', $job_ressource;
     
    166172      for my $job_pid ( keys %scheduled ) {
    167173         if ( waitpid( $job_pid, WNOHANG ) ) {
    168             $log_h->printf("end job %5i at %s\n", $job_num, time) if $logfile;
     174            $log_h->printf("end   job %5i at %s\n",
     175               $scheduled{$job_pid}->{num},
     176               time) if $logfile;
    169177            printf "end   job %5i / %5i at %s on node %s\n",
    170178               $scheduled{$job_pid}->{num},
     
    180188         }
    181189
    182                 $finished->send if $oar_checkpoint->count > 0 and keys(%scheduled) == 0;
     190      $finished->send if $oar_checkpoint->count > 0 and keys(%scheduled) == 0;
    183191
    184192      $finished->send if $job_todo->count == 0;
     
    191199$finished->wait;
    192200
    193 $log_h->close if $logfile;
     201$log_h->close() if $logfile;
     202
    194203
    195204__END__
Note: See TracChangeset for help on using the changeset viewer.