Example #1
0
 public function getStatus()
 {
     /* status check according to running.pid filename and platform relevant command */
     $batch_name = self::getBatchNameFromCommandLine($this->batch_name);
     $running = 0;
     $batch_indicators = self::getIndicatorFilesForBatch($batch_name);
     foreach ($batch_indicators as $ind) {
         $filename_parts = explode('.', $ind);
         if ($this->getProcessStatusByPid($filename_parts[2])) {
             $running++;
         } else {
             // indicator exists, process doesn't
             //echo "i should unlink now: ".$ind;
             unlink(myBatchBase::getBatchwatchPath() . $ind);
         }
     }
     return $running;
 }
Example #2
0
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */
require_once realpath(dirname(__FILE__)) . '/../config/sfrootdir.php';
define('SF_APP', 'kaltura');
define('SF_ENVIRONMENT', 'batch');
define('SF_DEBUG', true);
$PHP_CMD = "php";
require_once SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.php';
$batchwatch_job_list = array("batchConvertClient", "batchConvertServer", "batchBulkUpload", "batchDownloadVideoServer", "batchEmailServer", "batchEntryDeleteServer", "batchMobileUploadServer", "batchFlattenServer", "batchImportServer", "batchNotificationServer", "newBatchCommercialConvertServer", "newBatchConvertClient", "newBatchConvertServer");
$count = 0;
$sleep_time = 1;
$write_to_the_log_seconds = 120;
while (1) {
    try {
        $files = glob(myBatchBase::getBatchwatchPath() . "/*");
        SET_CONTEXT("batchWatch");
        // the files in this directory are supposed to be batch names to be started/stopped or restarted
        foreach ($files as $file) {
            $batch_name = pathinfo($file, PATHINFO_FILENAME);
            if ($batch_name == myBatchBase::REGISTERED_BATCHS) {
                continue;
            }
            // skip if the special file holding the registered batchs
            if ($batch_name[0] == "_") {
                continue;
            }
            //myBatchBase::IGNORE_PREFIX  ) continue;
            if (in_array($batch_name, $batchwatch_job_list)) {
                $command = file_get_contents($file);
                // TODO - change to fit the way we start / stop / restart