/** * @param Job $syncJob Laravel queue job * @param $arguments * @return bool * @throws \Unifact\Connector\Exceptions\HandlerException */ public function fire(Job $syncJob, $arguments) { try { $job = $this->jobRepo->findById($arguments['job_id']); $job->setPreviousStatus($arguments['previous_status']); $handler = forward_static_call([$job->handler, 'make']); $this->logger->debug("Preparing Job.."); if (!$handler->prepare()) { $this->logger->error('Handler returned FALSE in prepare() method, see log for details'); // delete Laravel queue job $syncJob->delete(); return false; } $this->logger->debug("Handling Job.."); if ($handler->handle($job) === false) { $this->logger->error('Handler returned FALSE in handle() method, see log for details'); // delete Laravel queue job $syncJob->delete(); return false; } $this->logger->debug("Completing Job.."); $handler->complete(); $this->logger->info('Finished Job successfully'); } catch (\Exception $e) { $this->oracle->exception($e); $this->logger->error('Exception was thrown in JobQueueHandler::fire method.'); $this->jobRepo->update($arguments['job_id'], ['status' => 'error']); // delete Laravel queue job $syncJob->delete(); return false; } // delete Laravel queue job $syncJob->delete(); return true; }
/** * @param $jobId * @param $stageId * @return \Illuminate\Contracts\View\View */ public function show($jobId, $stageId) { $stage = $this->stageRepo->findById($stageId); $previous = $this->stageRepo->getPrecedingStage($stage); if ($previous === null) { $previous = $this->jobRepo->findById($stage->job_id); } $logs = $this->logRepo->filter([['job_id', $stage->job_id], ['stage', $stage->stage]], 'id'); return \View::make('connector::stage.show', ['stage' => new StagePresenter($stage), 'previous' => $previous, 'logs' => $logs]); }
public function update($id) { $job = $this->jobRepo->findById($id); if (!empty(\Request::get('save_restart'))) { $this->jobRepo->update($id, ['data' => \Request::get('data'), 'status' => Job::STATUS_RESTART]); } elseif (!empty(\Request::get('restart'))) { $this->jobRepo->update($id, ['status' => Job::STATUS_RESTART]); } elseif (!empty(\Request::get('retry'))) { $this->jobRepo->update($id, ['status' => Job::STATUS_RETRY]); } return \Redirect::route('connector.jobs.show', [$id]); }