예제 #1
0
 /**
  * Run the scheduler that allows for delayed/scheduled gearman tasks
  *
  * @param int $every How many seconds to wait between checks
  * @param string $config Gearman configuration name
  */
 public function scheduler($every = 30, $config = 'default')
 {
     if ($every <= 0) {
         $this->error('Invalid number of seconds');
         $this->_stop(1);
     }
     $this->log('Waiting for scheduled tasks');
     while (true) {
         $jobId = Gearman::scheduled($config);
         if (!empty($jobId)) {
             $this->log('Job #' . $jobId . ' moved for immediate execution');
         } else {
             sleep($every);
         }
     }
 }