Esempio n. 1
0
require_once '/home/bshensky/vendor/autoload.php';
require_once 'includes/SpawnTranscoder.php';
require_once 'includes/JobFlusher.php';
require_once 'includes/JobController.php';
$q = isset($_REQUEST['q']) && !empty($_REQUEST['q']) ? $_REQUEST['q'] : 'spawn';
// the following seems to work with the mod_action handler for existing m3u8 files.  If the .htaccess file is rearchitected, this will need servicing too.
if (isset($_SERVER['PATH_TRANSLATED']) && !empty($_SERVER['PATH_TRANSLATED']) && file_exists($_SERVER['PATH_TRANSLATED'])) {
    $q = 'ping';
}
$j = new JobController($config['memcached']);
switch ($q) {
    case 'expire':
    case 'retire':
        // retire expire encoders - best to cron this as often as you are comfortable
        $threshold = isset($_REQUEST['threshold']) && !empty($_REQUEST['threshold']) ? $_REQUEST['threshold'] : MINIMUM_CRON_GRANULARITY;
        $jobs_killed = $j->expire_old_jobs_per_threshold($threshold);
        if (!empty($jobs_killed)) {
            echo "killed: " . implode(',', $jobs_killed);
        }
        break;
    case 'clean':
    case 'clear':
        // put down all encoders - start from ground zero
        $j->flush_all_jobs();
        break;
    case 'debug':
    case 'print':
        // reveal all jobs
        $format = isset($_REQUEST['format']) && !empty($_REQUEST['format']) ? $_REQUEST['format'] : DEFAULT_PRINT_FORMAT;
        $j->print_r_jobs($format);
        break;