Пример #1
0
if ($returncode) {
    $asset_meta['status'] = 'failed';
    $res = ezmam_asset_metadata_set($album, $asset, $asset_meta);
    lib_scheduling_error('Scheduler::job_perform[fail]{encode: ' . $cmd . '}(' . $returncode . ')[' . $dt . ' sec]');
    lib_scheduling_file_move(lib_scheduling_config('processing-path') . '/' . $job['basename'], lib_scheduling_config('failed-path') . '/' . $job['basename']);
    die;
}
// Retrieve the video from the renderer
$asset_meta['status'] = 'encoded';
$res = ezmam_asset_metadata_set($album, $asset, $asset_meta);
$cmd = $rsync_pgm . ' -L -r -e ssh -tv  --partial-dir=' . $render_finished_partial_upload_dir . ' ' . $renderer['client'] . '@' . $renderer['host'] . ':' . $renderer['processed_dir'] . '/' . $job_dir . ' ' . dirname($job['location'] . ' 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;
    }
}
// Retrieve fail
if ($err) {
    lib_scheduling_error('Scheduler::job_perform[fail]{rsync: ' . $cmd . '}(' . $err . ') |::>' . implode("\n", $out) . ' <::|');
    lib_scheduling_file_move(lib_scheduling_config('processing-path') . '/' . $job['basename'], lib_scheduling_config('failed-path') . '/' . $job['basename']);
    die;
}
// Retrieve Success
lib_scheduling_job_metadata_set($job, 'done', date('Y-m-d H:i:s'), lib_scheduling_config('processing-path'));
lib_scheduling_file_move(lib_scheduling_config('processing-path') . '/' . $job['basename'], lib_scheduling_config('processed-path') . '/' . $job['basename']);
lib_scheduling_file_move($job['location'], $render_finished_upload_dir . '/' . $job_dir);
Пример #2
0
/**
 * Take the semaphore
 */
function lib_scheduling_sema_take()
{
    global $semaphore;
    global $time;
    // try to get the semaphore
    if (my_sem_acquire_or_continue($semaphore)) {
        return;
    }
    // Remove semaphore if it is 30sec or more old to avoid dead locks
    $now = time();
    if ($time && $now - $time > 30) {
        lib_scheduling_warning('Scheduler::sema[deadlock]{remove semaphore}');
        lib_scheduling_file_rm(lib_scheduling_config('var-path') . lib_scheduling_config('sem-key') . '.sem');
    }
    // Wait for the semaphore
    my_sem_acquire($semaphore);
}
Пример #3
0
/**
 * Return the correct renderer based on a hostname
 * @param array $renderers The renderer list
 * @param string $hostname The renderer hostname
 * @return array The associated renderer or null
 */
function lib_scheduling_renderer_find($renderers, $hostname)
{
    foreach ($renderers as $renderer) {
        if ($renderer['host'] == $hostname) {
            return $renderer;
        }
    }
    lib_scheduling_warning('Scheduler::renderer_find[not found]{' . $hostname . '}');
    return null;
}