This commit is contained in:
2023-10-05 13:03:17 +03:00
parent 718cdb54f9
commit e037f770e5
9 changed files with 280 additions and 236 deletions
+20 -6
View File
@@ -22,7 +22,13 @@ class BuildController extends Controller
public function build()
{
exec("cd ".base_path(). " && php8.2 artisan {$this->channelService->channel->generateCommand} > /dev/null 2>&1 & echo $!",$op);
$buildLogFile = storage_path("build.log");
if(file_exists($buildLogFile)){
unlink($buildLogFile);
}
exec("cd " . base_path() . " && php8.2 artisan {$this->channelService->channel->generateCommand} > " . $buildLogFile . " 2>&1 & echo $!", $op);
$pid = (int)$op[0];
return redirect($this->channelService->channel->lucentUrl . "/build-report");
}
@@ -41,17 +47,25 @@ class BuildController extends Controller
{
return response()->stream(function () {
while (true) {
$curDate = time();
echo 'data: {"time": "' . $curDate . '"}';
$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";
logger( $curDate);
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(2); // 50ms
if (connection_aborted()) {
break;
}
sleep(1); // 50ms
}
}, 200, [
'Cache-Control' => 'no-cache',