IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 21, 2008, 6:38:46 PM (18 years ago)
Author:
bills
Message:

Updates to the postage stamp server scripts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/ppstamp_run.pl

    r16358 r16591  
    1515my $job_id = $ARGV[0];
    1616
    17 my $verbosity = 0;
     17my $verbosity = 1;
    1818
    1919use Sys::Hostname;
    2020my $host = hostname();
     21
    2122print "\n\n";
    2223print "Starting script $0 on $host\n\n";
     24
    2325use IPC::Cmd 0.36 qw( can_run run );
    2426
     
    5860        run(command => $command, verbose => $verbosity);
    5961    unless ($success) {
    60         die("Unable to perform pstamptool -pendingreq: $error_code");
     62        die("Unable to perform pstamptool -pendingjob: $error_code");
    6163    }
    6264
    6365    if (@$stdout_buf == 0) {
    6466        print STDERR "pending pstamp job id $job_id not found\n";
    65         exit 1;
     67        # exit 1;
     68        exit 0;
    6669    }
    6770    my $metadata = $mdcParser->parse(join "", @$stdout_buf) or
     
    8285my $outputBase = $psjob->{outputBase};
    8386my $argString = $psjob->{args};
    84 #my $request_id = $psjob->{req_id};
    85 
    86 #
    87 # update the state of this job from 'new' to 'run'
    88 #
    89 {
    90     my $command = "$pstamptool -processedjob -job_id $job_id -state run";
    91     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    92         run(command => $command, verbose => $verbosity);
    93     unless ($success) {
    94         die("Unable to perform $command: $error_code");
    95     }
    96 }
    9787
    9888my $jobStatus;
     
    10393
    10494    if ($success) {
    105         $jobStatus = "ok";
     95        $jobStatus = $PS_EXIT_SUCCESS;
    10696    } else {
    107         $jobStatus = $error_code;
    108         print STDERR "ppstamp failed with error code $error_code\n";
     97        # run shifts the unix exit status up by 8 bits for some reason
     98        $jobStatus = $error_code >> 8;
     99        print STDERR "ppstamp failed with error code: $jobStatus\n";
    109100    }
    110 #    unless ($success) {
    111 #        die("Unable to perform $command: $error_code");
    112 #    }
    113101}
    114102
    115103
    116 # stop the job and set the error status
     104# stop the job and set the result value
    117105{
    118     my $command = "$pstamptool -processedjob -job_id $job_id -state stop -status $jobStatus";
     106    my $command = "$pstamptool -processedjob -job_id $job_id -state stop -result $jobStatus";
    119107    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    120108        run(command => $command, verbose => $verbosity);
     
    124112}
    125113
    126 
    127 if ($jobStatus eq "ok") {
    128     exit 0;
    129 } else {
    130     exit $jobStatus;
    131 }
     114exit $jobStatus;
Note: See TracChangeset for help on using the changeset viewer.