示例#1
0
 /**
  * Start process action
  *
  * @param integer $id
  * @param boolen  $isChild
  * @throws Exception
  */
 public function processAction($id, $isChild = false)
 {
     if (!isset($this->_tasks[$id])) {
         throw new Exception("Task with ID '{$id}' not found");
     }
     ob_start();
     call_user_func($this->_tasks[$id], $id);
     if ($output = ob_get_clean()) {
         $output = PHP_EOL . 'Task #' . $id . ' output:' . PHP_EOL . $output . PHP_EOL;
     }
     AT_Log::log($output, false);
     if ($isChild) {
         echo AT_Process::SUCCESS_RESULT;
     } else {
         echo AT_Log::getLogs();
     }
 }
示例#2
0
 /**
  * Set log filename
  *
  * @param string $filename
  */
 public static function setFilename($filename)
 {
     self::$_filename = $filename;
 }
示例#3
0
 /**
  * Create process inside pool
  *
  * @return bool|null
  */
 public function createNew()
 {
     $id = array_shift($this->_haystack);
     if (null === $id) {
         return null;
     }
     $process = new AT_Process($id);
     if ($process->run()) {
         AT_Log::log("Task #" . $process->getId() . ' - Started');
         $this->_pool[] = $process;
         return true;
     }
     AT_Log::log('Could not create process');
     return false;
 }