/** * Run the task. * * @param string $logfile The log file to use. * * @return bool */ public function run($logfile) { $this->shutdownHandlerActive = true; $this->acquireLock(); try { $this->task->perform($logfile); } catch (\Exception $exception) { $this->logger->error($exception->getMessage()); $this->logger->error($this->task->getOutput()); } $this->releaseLock(); $this->shutdownHandlerActive = false; return Task::STATE_FINISHED === $this->task->getStatus(); }
/** * Convert a task to an array. * * @param Task $task The task to convert. * * @param bool $addOutput Flag determining if the output shall get added or not. * * @param null $outputOffset The output offset to use. * * @return array */ private function convertTaskToArray(Task $task, $addOutput = false, $outputOffset = null) { $data = ['id' => $task->getId(), 'status' => $task->getStatus(), 'type' => $task->getType(), 'created_at' => $task->getCreatedAt()->format(\DateTime::ISO8601), 'user_data' => $task->getUserData()]; if (true === $addOutput) { $data['output'] = $task->getOutput($outputOffset); } return $data; }