Beispiel #1
0
 /**
  * @param array $commands
  */
 public function saveSchedulerCommands(array $commands)
 {
     $dir = $this->taskConfig->getCommandsDir();
     $type = $this->taskConfig->type;
     $res = self::createDir($dir);
     if (!$res) {
         return;
     }
     $path = "{$dir}/{$type}.cmd";
     KScheduleHelperManager::saveCommands($path, $commands);
 }
 private function loadCommands()
 {
     $commands = KScheduleHelperManager::loadCommands($this->schedulerConfig->getCommandsDir());
     if (!$commands || !is_array($commands) || !count($commands)) {
         return;
     }
     //		KalturaLog::info(count($commands) . " commands found");
     $command_results = array();
     foreach ($commands as $command) {
         if ($command instanceof KalturaBatchQueuesStatus) {
             $this->handleQueueStatus($command->workerId, $command->size);
         } elseif ($command instanceof KalturaSchedulerConfig) {
             $command_results[] = $this->handleConfig($command);
         } elseif ($command instanceof KalturaControlPanelCommand) {
             $command_results[] = $this->handleCommand($command);
         } else {
             KalturaLog::err("command of type " . get_class($command) . " could not be handled");
         }
     }
     $cnt = count($command_results);
     if ($cnt) {
         $path = $this->schedulerConfig->getCommandResultsFilePath();
         KalturaLog::info("Sending {$cnt} command results to the server [{$path}]");
         KScheduleHelperManager::saveCommands($path, $command_results);
     }
 }