コード例 #1
0
ファイル: Worker.php プロジェクト: bryanashley/framework
 /**
  * Register the worker timeout handler (PHP 7.1+).
  *
  * @param  \Illuminate\Contracts\Queue\Job|null  $job
  * @param  WorkerOptions  $options
  * @return void
  */
 protected function registerTimeoutHandler($job, WorkerOptions $options)
 {
     if (version_compare(PHP_VERSION, '7.1.0') < 0 || !extension_loaded('pcntl')) {
         return;
     }
     $timeout = $job && !is_null($job->timeout()) ? $job->timeout() : $options->timeout;
     pcntl_async_signals(true);
     pcntl_signal(SIGALRM, function () {
         $this->exceptions->report(new TimeoutException('A queue worker timed out while processing a job.'));
         exit(1);
     });
     pcntl_alarm($timeout + $options->sleep);
 }