Example
There is no need to inform the back end script of the path to the API libraries.
use qb; use DBI;
my $job = qb::jobobj();
while(1) {
my $frame = qb::requestwork();
last if ($frame->{"status"} eq "complete");
if ($frame->{"status"} eq "blocked") {
print "job $job->{id} has been blocked.\n"; qb::reportjob("blocked");
exit(0);
}
print "running frame: ", $frame->{name}, "\n";
print "\tcommand: ", $job->{package}->{cmdline}, "\n";
system($job->{package}->{cmdline});
$frame->{"status"} = "complete";
qb::reportwork($frame); }
- First, get the job object. The object is the one passed to the qb::submit() function.
- Enter a loop, and wait for work to come from the (Supervisor) frame server:
- The qb::requestwork() call blocks the subjob until it gets an agenda item from the Supervisor. We'll call this a frame.
- Before we handle the frame, check its status. If it is complete, end the job.
- If the frame is blocked, go ahead and quit as well.
- Otherwise, print out the frame number, and execute the command.
- Once that has been accomplished, register the completed frame with the Supervisor.