]> mj.ucw.cz Git - bex.git/blobdiff - brun
TODO
[bex.git] / brun
diff --git a/brun b/brun
index 3e46d4700571b07621a48ed9991863b872a21f22..040b6ba40d66d6abc9f83bd8b00401062a76e069 100755 (executable)
--- a/brun
+++ b/brun
@@ -38,7 +38,7 @@ sub update_status($$$$;$) {
                print $status_fd "! $mach $job $status\n";
        }
        if ($log_on_queue) {
-               $log_on_queue->log($mach, $job, $status, $msg);
+               $log_on_queue->update_job_status($mach, $job, $status, $msg);
        }
 }
 
@@ -121,13 +121,13 @@ sub run_job_body($$$) {
 
        update_status($mach, $jid, 'SEND', undef);
        my $cmd = 't=$(mktemp -t bex-XXXXXXXX) && cat >$t && chmod u+x $t && echo $t';
-       my $rtmp = `ssh <$tmp $host '$cmd'`;
+       my $rtmp = `$BEX::Config::ssh_command <$tmp $host '$cmd'`;
        !$? && defined($rtmp) && $rtmp ne '' or return ('NOXFER', 'Transfer failed');
        chomp $rtmp;
 
        update_status($mach, $jid, 'RUN', $queue);
        my $lf = $queue->log_file($mach, $jid);
-       system 'bash', '-o', 'pipefail', '-c', "ssh -t $host '$rtmp ; e=\$? ; rm -f $rtmp ; exit \$e' 2>&1 | tee -a $lf";
+       system 'bash', '-o', 'pipefail', '-c', "$BEX::Config::ssh_command $host '$rtmp ; e=\$? ; rm -f $rtmp ; exit \$e' 2>&1 | tee -a $lf";
        if ($?) {
                return ('FAILED', 'Job failed ' . exit_status($?));
        } else {
@@ -167,23 +167,14 @@ for my $mach (@machines) {
                        $jid eq $given_job or next;
                }
                my $job = BEX::Job->new_from_file($queue->job_file($jid));
+               update_status($mach, $jid, 'INIT', undef);
                if (!$queue->lock($mach, $jid)) {
                        print "### Skipping locked $jid on $mach ###\n";
                        update_status($mach, $jid, 'LOCKED', undef);
                        next;
                }
-               my $stat = {
-                       'Time' => time,
-               };
-               print "### Running $jid (", $job->attr('Subject'), ") on $mach ###\n";
+               print "### Running ", $job->name, " on $mach ###\n";
                my ($s, $msg) = run_job($job, $queue, $mach);
-
-               $stat->{'Status'} = $s;
-               $stat->{'Message'} = $msg;
-               $queue->write_job_status($mach, $jid, $stat);
-
-               # Called after writing the status file, so that the front-end watching
-               # our status FIFO can see the new status file.
                update_status($mach, $jid, $s, $queue, $msg);
 
                if ($s eq 'OK') {
@@ -197,6 +188,7 @@ for my $mach (@machines) {
                        }
                }
        }
+} continue {
        update_status($mach, '-', 'DONE', undef);
 }
 $queue->unlock;