channelService->channel->generateCommand} > " . $buildLogFile . " 2>&1 & echo $!", $op); $pid = (int)$op[0]; return redirect($this->channelService->channel->lucentUrl . "/build-report"); } public function report(): View { return $this->svelte->render( layout: "channel", view: "buildReport", title: "Build Report", ); } public function reportSource() { return response()->stream(function () { while (true) { $data["date"] = date("Y-m-d H:i:s"); $data["logs"] = file_get_contents(storage_path("build.log")); $lines = explode("\n",$data["logs"]); echo 'data: ' .json_encode($data); echo "\n\n"; ob_flush(); flush(); if(in_array("Finito",$lines)){ break; } // Break the loop if the client aborted the connection (closed the page) if (connection_aborted()) { break; } sleep(1); // 50ms } }, 200, [ 'Cache-Control' => 'no-cache', 'X-Accel-Buffering' => 'no', 'Content-Type' => 'text/event-stream', ]); } }