date = $date; $this->download = $download; } /** * Execute the job. */ public function handle(): void { $projectFolder = base_path('../'); $command = [ sprintf('%srunpython.sh', $projectFolder), sprintf('--date=%s', $this->date->format('Y-m-d')), sprintf('--days=%d', $this->days), ]; // Convert commands array to a single string $process = new Process($command); $process->setTimeout(3600); // stel een geschikte timeout in $process->start(); try { $process->wait(function ($type, $buffer) use (&$myOutput) { logger($buffer); }); } catch (ProcessFailedException $exception) { logger('error', $exception->getMessage()); } $this->download->update([ 'status' => 'completed', ]); } public static function handleForDate(Project $project, Carbon $date) { $filename = sprintf('%s.tif', $date->format('Y-m-d')); if ($project->downloads()->where(['status' => 'completed', 'name' => $filename])->count() > 0) { return; } $path = sprintf('%s/%s/%s', $project->download_path, 'merged_final_tif', $filename); return new self( $project->downloads()->create([ 'name' => $filename, 'path' => $path, 'status' => 'completed', ]), $date ); } }