/** * Process a single job * * @param Job $job The job to be processed. */ public function perform(Job $job) { // Set timeout so as to stop any hanged jobs // and turn off displaying errors as it fills // up the console set_time_limit($this->timeout); ini_set('display_errors', 0); $job->perform(); switch ($job->getStatus()) { case Job::STATUS_COMPLETE: $this->log('Done job <pop>' . $job . '</pop> in <pop>' . $job->execTimeStr() . '</pop>', Logger::INFO); break; case Job::STATUS_CANCELLED: $this->log('Cancelled job <pop>' . $job . '</pop>', Logger::INFO); break; case Job::STATUS_FAILED: $this->log('Job ' . $job . ' failed: "' . $job->failError() . '" in ' . $job->execTimeStr(), Logger::ERROR); break; default: $this->log('Unknown job status "(' . gettype($job->getStatus()) . ')' . $job->getStatus() . '" for <pop>' . $job . '</pop>', Logger::WARNING); break; } }