Exemplo n.º 1
0
 /**
  * Update the status of the current job.
  *
  * @param int $status Status constant from Resque_Job_Status indicating the current status of a job.
  */
 public function updateStatus($status)
 {
     if (empty($this->payload['id'])) {
         return;
     }
     $statusInstance = new \Resque_Job_Status($this->payload['id']);
     $statusInstance->update($status);
 }
Exemplo n.º 2
0
 public static function update($status, $to_job_id, $namespace)
 {
     \Resque::setBackend('127.0.0.1:6379');
     if (!empty($namespace)) {
         \Resque_Redis::prefix($namespace);
     }
     $job = new \Resque_Job_Status($to_job_id);
     if (!$job->get()) {
         throw new \RuntimeException("Job {$to_job_id} was not found");
     }
     $class = new \ReflectionObject($job);
     foreach ($class->getConstants() as $constant_value) {
         if ($constant_value == $status) {
             $job->update($status);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * Re-queue the current job.
  * @return string
  */
 public function recreate()
 {
     $status = new Resque_Job_Status($this->payload['id']);
     $monitor = false;
     if ($status->isTracking()) {
         $monitor = true;
         $status->update(Resque_Job_Status::STATUS_WAITING);
     }
     $this->worker->logger->log(Psr\Log\LogLevel::NOTICE, 'Requeing {job}', array('job' => $this));
     Resque::redis()->lrem('working:' . $this->queue, 0, $this->payload['id']);
     Resque_Event::trigger('onRecreate', array('job' => $this));
     return self::create($this->queue, $this->payload['class'], $this->getArguments(), $monitor, $this->payload['id']);
 }