Ejemplo n.º 1
0
 private function tryRunTask($taskId)
 {
     // check limit
     if ($this->taskDao->countRunning() >= self::TASK_POOL_SIZE) {
         $this->logger->warn('Task pool is full.');
         return;
     }
     $task = $this->taskDao->find($taskId);
     $jobId = $task['job_id'];
     // check signal
     $jobIds = $this->jobDao->getDependencies($jobId);
     if (count($jobIds) > 0) {
         if (!$this->jobDao->checkSignals($jobIds, $this->now->format('Y-m-d'))) {
             $this->logger->debug("Task {$taskId} is waiting for signal.");
             return;
         }
     }
     // run task
     $this->taskDao->updateStatus($taskId, SchedulerTaskDao::STATUS_RUNNING);
     $this->jobDao->updateTaskStatus($jobId, SchedulerTaskDao::STATUS_RUNNING);
     shell_exec('php ' . __DIR__ . '/launcher.php scheduler_run.php ' . $taskId . ' >/dev/null 2>&1 &');
     $this->logger->info("Run task [id: {$taskId}, job_id: {$jobId}]");
 }