Esempio n. 1
0
 protected function startMonitor(array $files)
 {
     if ($this->monitorHandle && is_resource($this->monitorHandle)) {
         return;
     }
     $killConfig = new KBatchKillerConfig();
     $killConfig->pid = getmypid();
     $killConfig->maxIdleTime = self::$taskConfig->getMaxIdleTime();
     $killConfig->sleepTime = self::$taskConfig->getMaxIdleTime() / 2;
     /*
     Do not run killer process w/out set config->maxIdle
     */
     if ($killConfig->maxIdleTime <= 0 || is_null($killConfig->maxIdleTime)) {
         KalturaLog::info(__METHOD__ . ': The MaxIdleTime is not set properly. The Killer job will not run');
         return;
     }
     $killConfig->files = $files;
     //$killConfig->files = array("/root/anatol/0_phxt8hsa.api.log");
     $killConfig->sessionKey = $this->sessionKey;
     $killConfig->batchIndex = $this->getIndex();
     $killConfig->batchName = $this->getName();
     $killConfig->workerId = $this->getId();
     $killConfig->workerType = $this->getType();
     $killConfig->schedulerId = $this->getSchedulerId();
     $killConfig->schedulerName = $this->getSchedulerName();
     $killConfig->dwhPath = self::$taskConfig->getDwhPath();
     $killConfig->dwhEnabled = self::$taskConfig->getDwhEnabled();
     $phpPath = 'php';
     // TODO - get it from somewhere
     $killerPath = $this->getMonitorPath();
     $killerPathStr = base64_encode(serialize($killConfig));
     $cmdLine = "{$phpPath} {$killerPath} {$killerPathStr}";
     $descriptorspec = array();
     // stdin is a pipe that the child will read from
     $other_options = array('suppress_errors' => FALSE, 'bypass_shell' => FALSE);
     KalturaLog::debug("Killer config:\n" . print_r($killConfig, true));
     KalturaLog::debug("Now executing [{$cmdLine}]");
     KalturaLog::info('Starting monitor');
     $this->monitorHandle = proc_open($cmdLine, $descriptorspec, $pipes, null, null, $other_options);
 }