コード例 #1
0
ファイル: PHPCron.php プロジェクト: dmamontov/symfony-phpcron
 /**
  * Execution records individually.
  * @param integer $id
  * @param array $entrie
  * @return boolean
  */
 protected function execEntrie($id, $entrie)
 {
     $pid = pcntl_fork();
     if ($pid == -1) {
         return false;
     } elseif ($pid) {
         $this->running[$pid] = $id;
     } else {
         while (is_null(Config::$sharedId) == false && @shm_has_var(Config::$sharedId, Config::PID)) {
             $currentTime = new \DateTime();
             if (Entries::check($entrie, $currentTime)) {
                 $process = new Process($entrie['cmd']);
                 $process->run();
                 if ($process->isSuccessful()) {
                     sleep(Config::setSleep($entrie, $currentTime));
                     exit;
                 }
             } else {
                 sleep(Config::setSleep($entrie, $currentTime));
             }
         }
         exit;
     }
 }