Exemplo n.º 1
4
 /**
  * Run the worker instance.
  *
  * @param  string  $connection
  * @param  string  $queue
  * @param  int  $delay
  * @param  int  $memory
  * @param  bool  $daemon
  * @return array
  */
 protected function runWorker($connection, $queue, $delay, $memory, $daemon = false)
 {
     if ($daemon) {
         $this->worker->setCache($this->laravel['cache']->driver());
         $this->worker->setDaemonExceptionHandler($this->laravel['Illuminate\\Contracts\\Debug\\ExceptionHandler']);
         return $this->worker->daemon($connection, $queue, $delay, $memory, $this->option('sleep'), $this->option('tries'));
     }
     return $this->worker->pop($connection, $queue, $delay, $this->option('sleep'), $this->option('tries'));
 }
Exemplo n.º 2
4
 /**
  * Run the worker instance.
  *
  * @param  string  $connection
  * @param  string  $queue
  * @return array
  */
 protected function runWorker($connection, $queue)
 {
     $this->worker->setCache($this->laravel['cache']->driver());
     $method = $this->option('once') ? 'runNextJob' : 'daemon';
     return $this->worker->{$method}($connection, $queue, $this->gatherWorkerOptions());
 }
 /**
  *  Process the job
  * 
  */
 protected function processJob($connectionName, $id)
 {
     $manager = $this->worker->getManager();
     $connection = $manager->connection($connectionName);
     $job = $connection->getJobFromId($id);
     // If we're able to pull a job off of the stack, we will process it and
     // then immediately return back out. If there is no job on the queue
     // we will "sleep" the worker for the specified number of seconds.
     if (!is_null($job)) {
         $sleep = max($job->getDatabaseJob()->available_at - time(), 0);
         sleep($sleep);
         return $this->worker->process($manager->getName($connectionName), $job);
     }
     return ['job' => null, 'failed' => false];
 }