mosaic = $mosaic; } /** * Execute the job. */ /** * Execute the job. */ public function handle(): void { $projectFolder = base_path('../'); $command = [ sprintf('%sbuild_mosaic.sh', $projectFolder), sprintf('--end_date=%s', $this->mosaic->end_date->format('Y-m-d')), sprintf('--offset=%s', $this->mosaic->offset), sprintf('--data_dir=%s', $this->mosaic->project->download_path), ]; $currentPath = '/usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin/Users/mfolkerts/anaconda3/bin:/Library/Apple/usr/bin'; try{ $process = ProcessNew::timeout(220) ->env(['PATH' => $currentPath . ':/usr/local/Cellar/pandoc/3.1.8/bin/pandoc']) ->start($command, function (string $type, string $output ) { logger($output); }); $results = $process->wait(); if($results->successful()){ $this->mosaic->setStatusSuccess(); } }catch(\RuntimeException|ProcessTimedOutException|ProcessFailedException $e){ echo $e->getMessage(); $this->mosaic->setStatusFailed(); } } /** * Check if the project has a mosaic for given period. */ public static function handleFor(Project $project,Carbon $endDate, int $offset): NullJob|ProjectMosiacGeneratorJob { logger("ProjectMosiacGeneratorJob::handleFor($endDate, $offset)"); if ($project->hasInvalidMosaicFor($endDate,$offset)) { logger("ProjecMosaicGeneratorJob::handleFor(end_date: $endDate, offset: $offset): InvalidMosaic."); return new NullJob(); } $week = $endDate->clone()->next($project->mail_day)->week; $year = $endDate->clone()->next($project->mail_day)->year; /** * @var ProjectMosaic $mosaic */ $mosaic = $project->mosaics()->updateOrCreate( [ 'end_date' => $endDate, 'offset' => $offset, ], [ 'name' => sprintf('Week_%s_%s', $week, $year), 'path' => sprintf('%s/%s/%s', $project->download_path, 'mosaics', sprintf('week_%s_%s.tif', $week, $year) ), 'end_date' => $endDate->format('Y-m-d'), 'offset' => $offset, ]); return new self($mosaic); } }