Changeset 83 for trunk/oarutils


Ignore:
Timestamp:
Jun 1, 2012, 5:58:28 PM (12 years ago)
Author:
g7moreau
Message:
  • Add folder parameter
  • Rewrite notify async section
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/oarutils/oar-parexec

    r82 r83  
    8282      my ($job_name) = $job_cmd =~ m/#.*?\bname=(\S+?)\b/i;
    8383      $job_name ||= $job_num;
    84       push @job, { name => $job_name, cmd => "$job_cmd" };
     84      my ($job_folder) = $job_cmd =~ m/#.*?\bfolder=(\S+?)\b/i;
     85      $job_folder ||= './';
     86      push @job, { name => $job_name, cmd => "$job_cmd", folder => $job_folder };
    8587      }
    8688   close JOB_LIST;
     
    157159# asynchrone notify job
    158160async {
     161   NOTIFY:
    159162   while () {
    160       next if $oar_checkpoint->count() == 0;
    161 
    162163      # only notify with transmit flag
    163       if (not $sig_transmit) {
    164          cede;
    165          next;
     164      if ($sig_transmit and $oar_checkpoint->count() > 0) {
     165
     166     for my $job_pid (keys %scheduled) {
     167        my $job_name     = $scheduled{$job_pid}->{name};
     168        my $job_pidfile  = $scheduled{$job_pid}->{pidfile};
     169        my $node_connect = $scheduled{$job_pid}->{node_connect};
     170
     171        my $fh = IO::File->new();
     172        $fh->open("| $oarsh $node_connect >/dev/null 2>&1")
     173           or die "error: can't notify subjob: $!";
     174
     175        $fh->autoflush;
     176        $fh = unblock $fh;
     177
     178        $fh->print("kill -$sig_checkpoint \$(cat $job_pidfile)");
     179        $fh->print("exit\n");
     180
     181        print "warning: transmit signal $sig_checkpoint"
     182           . " to $job_name on $node_connect.\n"
     183           if $verbose;
     184
     185        close $fh;
     186        cede;
     187        }
    166188         }
    167189
    168       for my $job_pid (keys %scheduled) {
    169          my $job_name     = $scheduled{$job_pid}->{name};
    170          my $job_pidfile  = $scheduled{$job_pid}->{pidfile};
    171          my $node_connect = $scheduled{$job_pid}->{node_connect};
    172 
    173          my $fh = IO::File->new();
    174          $fh->open("| $oarsh $node_connect >/dev/null 2>&1")
    175             or die "error: can't notify subjob: $!";
    176 
    177          $fh->autoflush;
    178          $fh = unblock $fh;
    179 
    180          $fh->print("kill -$sig_checkpoint \$(cat $job_pidfile)");
    181          $fh->print("exit\n");
    182 
    183          print "warning: transmit signal $sig_checkpoint"
    184             . " to $job_name on $node_connect.\n"
    185             if $verbose;
    186 
    187          close $fh;
    188          cede;
    189          }
     190      cede;
    190191      }
    191192   }
     
    195196   JOB:
    196197   for my $job (@job) {
    197       my $job_name = $job->{name};
    198       my $job_cmd  = $job->{cmd};
     198      my $job_name   = $job->{name};
     199      my $job_cmd    = $job->{cmd};
     200      my $job_folder = $job->{folder};
    199201
    200202      # job has been already run ?
     
    259261         }
    260262      $fh->print("cd $current_dir\n");
     263      $fh->print("cd $job_folder\n");
    261264      if ($sig_transmit) {
    262265         $fh->print("trap 'kill -$sig_checkpoint \$(jobs -p)' $sig_checkpoint\n");
Note: See TracChangeset for help on using the changeset viewer.