示例#1
0
/**
 * Kill a job on the corresponding renderer
 *
 * @param string $uid The job id
 * @return boolean Whether the job has been successfully killed
 */
function scheduler_job_kill($uid)
{
    $job = lib_scheduling_job_find(scheduler_processing_get(), $uid);
    $renderer = lib_scheduling_renderer_find(lib_scheduling_renderer_list(), $job['renderer']);
    $status = lib_scheduling_renderer_job_kill($renderer, $job);
    if ($status) {
        lib_scheduling_notice('Scheduler::renderer_job_kill[success]{' . $job['uid'] . '(' . $job['album'] . ' - ' . $job['asset'] . ') on ' . $renderer['host'] . '}');
    } else {
        lib_scheduling_alert('Scheduler::renderer_job_kill[fail]{' . $job['uid'] . '(' . $job['album'] . ' - ' . $job['asset'] . ') on ' . $renderer['host'] . '}');
    }
    return $status;
}
$cmd = $rsync_pgm . ' -L -r -e ssh -tv  --partial-dir=' . $renderer['downloading_dir'] . ' ' . $job['location'] . ' ' . $renderer['client'] . '@' . $renderer['host'] . ':' . $renderer['downloaded_dir'] . ' 2>&1';
// try 3 times
for ($i = 0; $i < 3; $i++) {
    exec($cmd, $out, $err);
    if ($err) {
        lib_scheduling_warning('Scheduler::job_perform[wait]{rsync: ' . $cmd . '}(' . $err . ') |::>' . implode("\n", $out) . ' <::|');
        sleep(600);
    } else {
        break;
    }
}
// Send fail
if ($err) {
    lib_scheduling_error('Scheduler::job_perform[fail]{rsync: ' . $cmd . '}(' . $err . ') |::> ' . implode("\n", $out) . ' <::|');
    // tag the renderer as not repsonding
    $renderers = lib_scheduling_renderer_list();
    foreach ($renderers as $_) {
        if ($_['host'] == $renderer['host']) {
            $_['status'] = 'not responding';
        }
    }
    lib_scheduling_renderer_generate($renderers);
    lib_scheduling_alert('Scheduler::job_perform[not responding]{renderer: ' . $renderer['host'] . '}');
    // move the job back to the queue
    lib_scheduling_file_move(lib_scheduling_config('processing-path') . '/' . $job['basename'], lib_scheduling_config('queue-path') . '/' . $job['basename']);
    die;
}
// Launch the rendering
$cmd = $ssh_pgm . ' ' . $renderer['client'] . '@' . $renderer['host'] . ' "' . $renderer['launch'] . ' ' . $job_dir . ' 2>&1"';
$t1 = time();
exec($cmd, $cmdoutput, $returncode);