mosaic = $mosaic; } /** * Execute the job. */ public function handle(): void { $weeksAgo = ProjectReport::weeksAgoForYearAndWeek($this->mosaic->year, $this->mosaic->week); $projectFolder = base_path('../'); $command = [ sprintf('%sbuild_mosaic.sh', $projectFolder), sprintf('--weeks_ago=%s', $weeksAgo), ]; $process = new Process($command); $process->setTimeout(120); $currentPath = 'usr/bin:/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin/Users/mfolkerts/anaconda3/bin:/Library/Apple/usr/bin'; $process->setEnv(['PATH' => $currentPath.':/usr/local/Cellar/pandoc/3.1.8/bin/pandoc']); // $process->setTimeout(36000); // stel een geschikte timeout in $process->start(); try { $myOutput = []; $process->wait(function ($type, $buffer) use (&$myOutput) { // $this->stream(to: 'processOutput', content: $buffer); $myOutput[] = $buffer; logger($buffer); }); $this->processOutput = collect($myOutput)->join('\n'); } catch (ProcessFailedException $exception) { echo $exception->getMessage(); } $this->mosaic->update([ 'status' => 'complete', ]); } public static function handleFor(Project $project, $year, $startWeekNumber) { if ($project->mosaics()->where(['status' => 'complete', 'year' => $year, 'week' => $startWeekNumber])->count() > 0) { return; } $mosaic = $project->mosaics()->create([ 'name' => sprintf('Week %d, %d', $startWeekNumber, $year), 'path' => sprintf('%s/%s/%s', $project->download_path, 'mosaics', sprintf('week_%d_%d.tif', $startWeekNumber, $year)), 'year' => $year, 'week' => $startWeekNumber, 'status' => 'pending', ]); return new self($mosaic); } }