Changeset 38 for trunk/oarutils/oar-parexec
- Timestamp:
- Dec 4, 2011, 11:04:19 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oarutils/oar-parexec
r37 r38 17 17 18 18 my $file = ''; 19 my $logfile = ''; 19 20 my $verbose; 20 21 my $job_np = 1; … … 27 28 Getopt::Long::GetOptions( 28 29 'file=s' => \$file, 30 'logfile=s' => \$logfile, 29 31 'verbose' => \$verbose, 30 32 'help' => \$help, … … 38 40 pod2usage( -verbose => 2 ) if not -e $file; 39 41 42 my %state; 43 my $log_h = IO::File->new(); 44 if (-e $logfile) { 45 $log_h->open("< $logfile") 46 or die "can't read log file: $!"; 47 while (<$log_h>) { 48 $state{$1} = 'start' if m/^start\sjob\s(\d+)/; 49 $state{$1} = 'end' if m/^end\sjob\s(\d+)/; 50 } 51 $log_h->close(); 52 } 53 if ($logfile) { 54 $log_h->open(">> $logfile") 55 or die "can't open log file: $!"; 56 $log_h = unblock $log_h; 57 } 58 40 59 my @job = (); 41 60 open( JOB_LIST, '<', "$file" ) or die "can't open $file: $!"; … … 87 106 async { 88 107 for my $job (@job) { 108 $job_num++; 109 if (exists $state{$job_num} and $state{$job_num} eq 'end') { 110 delete $state{$job_num}; 111 cede; 112 next; 113 } 114 if (exists $state{$job_num} and $state{$job_num} eq 'start') { 115 print "warning: job $job_num was not finished, relaunching...\n" if $verbose; 116 } 117 89 118 my $job_ressource = $ressources->get; 90 91 $job_num++;92 119 93 120 my ($node_connect) = split ',', $job_ressource; … … 101 128 $scheduled{$job_pid} = { fh => $fh, node_connect => $node_connect, ressource => $job_ressource, num => $job_num }; 102 129 130 $log_h->printf("start job %5i at %s\n", $job_num, time) if $logfile; 103 131 printf "start job %5i / %5i at %s on node %s\n", 104 132 $job_num, $job_pid, time, $job_ressource … … 133 161 for my $job_pid ( keys %scheduled ) { 134 162 if ( waitpid( $job_pid, WNOHANG ) ) { 163 $log_h->printf("end job %5i at %s\n", $job_num, time) if $logfile; 135 164 printf "end job %5i / %5i at %s on node %s\n", 136 165 $scheduled{$job_pid}->{num}, … … 155 184 $finished->wait; 156 185 186 $log_h->close if $logfile; 187 157 188 __END__ 158 189
Note: See TracChangeset
for help on using the changeset viewer.