/** * Execute the console command * * @return void */ public function fire() { $job_name = $this->argument('jobname'); list($collection_uri, $name) = InputController::getParts($job_name); // Check if the job exists $job = \Job::where('name', '=', $name)->where('collection_uri', '=', $collection_uri)->first(); if (empty($job)) { $this->error("The job with identified by: {$job_name} could not be found.\n"); exit; } $this->line('The job has been found.'); $job_exec = new JobExecuter($job, $this); $job_exec->execute(); }
/** * Execute the console command * * @return void */ public function fire() { // Check for a list option $list = $this->option('list'); $job_name = $this->argument('jobname'); if (empty($list) && !empty($job_name)) { $inputController = new InputController(); list($collection_uri, $name) = $inputController->getParts($job_name); // Check if the job exists $job = \Job::where('name', '=', $name)->where('collection_uri', '=', $collection_uri)->first(); if (empty($job)) { $this->error("The job with identified by: {$job_name} could not be found.\n"); exit; } $this->info('The job has been found.'); // Configure a log handler if configured $this->addLogHandler(); $startDate = new Carbon(); $iso8601 = $startDate->toISo8601String(); \Log::info("Executing job {$name} at {$iso8601}"); try { $job_exec = new JobExecuter($job, $this); $job_exec->execute(); } catch (\Exception $ex) { $endDate = new Carbon(); $iso8601 = $endDate->toISO8601String(); \Log::error("The job {$job_name} has failed at {$iso8601}"); \Log::error($ex->getMessage()); \Log::error($ex->getTraceAsString()); } $endDate = new Carbon(); $iso8601 = $endDate->toISO8601String(); $job->date_executed = time(); $job->added_to_queue = false; $job->save(); \Log::info("The job has ended at {$iso8601}"); } else { $jobs = \Job::all(['name', 'collection_uri'])->toArray(); if (!empty($jobs)) { $this->info("=== Job names ==="); foreach ($jobs as $job) { $this->info($job['collection_uri'] . '/' . $job['name']); } } else { $this->info("No jobs found."); } } }