<?php

/**
 *  
 * @package Scheduler
 */
if (strtoupper(PHP_SAPI) != 'CLI' && strtoupper(PHP_SAPI) != 'CGI-FCGI') {
    echo 'This script must be executed using CLI';
    exit;
}
$phpPath = 'php';
if (isset($argc) && $argc > 1) {
    $phpPath = $argv[1];
} else {
    if (isset($_SERVER['PHP_PEAR_PHP_BIN'])) {
        $phpPath = $_SERVER['PHP_PEAR_PHP_BIN'];
    }
}
$iniFile = dirname(__FILE__) . "/../configurations/batch.ini";
// should be the full file path
if (isset($argc) && $argc > 2) {
    $iniFile = $argv[2];
}
if (!file_exists($iniFile)) {
    die("Configuration file [{$iniFile}] not found.");
}
require_once "bootstrap.php";
$kscheduler = new KGenericScheduler($phpPath, $iniFile);
$kscheduler->run();
示例#2
0
    case 'stop':
        win32_stop_service($serviceName);
        KalturaLog::info('Service Stopped');
        exit(0);
    case 'run':
        win32_start_service_ctrl_dispatcher($serviceName);
        win32_set_service_status(WIN32_SERVICE_RUNNING);
        break;
    case 'debug':
        set_time_limit(10);
        break;
    default:
        KalturaLog::info('Unkown action');
        exit(-1);
}
$kscheduler = new KGenericScheduler($phpPath, $iniDir);
while (1) {
    //Handle Windows Service Request
    if ($serviceAction == 'run') {
        switch (win32_get_last_control_message()) {
            case WIN32_SERVICE_CONTROL_CONTINUE:
                break;
            case WIN32_SERVICE_CONTROL_INTERROGATE:
                win32_set_service_status(WIN32_NO_ERROR);
                break;
            case WIN32_SERVICE_CONTROL_STOP:
                KalturaLog::info('Service stopped gracefully');
                if (file_exists($pid)) {
                    unlink($pid);
                }
                win32_set_service_status(WIN32_SERVICE_STOPPED);