projectReport = $projectReport; $this->sendMail = $sendMail; } /** * Execute the job. */ public function handle() { // TODO check the changements due to migration $projectFolder = base_path('../'); $command = [ sprintf('%sbuild_report.sh', $projectFolder), sprintf('--filename=%s', $this->projectReport->getFullPathName()), sprintf('--report_date=%s', $this->projectReport->getReportDate()), sprintf('--mail_day=%s', $this->project->download_path->mail_day), sprintf('--data_dir=%s', $this->projectReport->project->download_path), ]; logger('command:'. print_r($command, true)); // Convert commands array to a single string $process = new Process($command); $process->setTimeout(220); $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'); $this->projectReport->setStatusSuccess(); } catch (ProcessFailedException $exception) { echo $exception->getMessage(); $this->projectReport->setStatusFailed(); } $this->sendMail(); } private function sendMail(): void { if ($this->sendMail && $this->projectReport->statusIsSuccessful()) { logger('sendMail'); MailingForm::saveAndSendMailing( $this->projectReport, $this->projectReport->project->mail_subject, $this->projectReport->project->mail_template, $this->projectReport->project->emailRecipients()->get(['email', 'name'])->toArray() ); } } }