From 8545217cc3b273a6fc3ccbfadb9d5112d2b8f00a Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 2 Mar 2023 20:54:39 +0100 Subject: [PATCH] Fix process related errors --- Blacklight/TmuxOutput.php | 4 ++-- Blacklight/libraries/Forking.php | 17 +++++++++++++---- app/Console/Commands/TmuxUIStart.php | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Blacklight/TmuxOutput.php b/Blacklight/TmuxOutput.php index 15293a280..9dd5d7250 100755 --- a/Blacklight/TmuxOutput.php +++ b/Blacklight/TmuxOutput.php @@ -110,8 +110,8 @@ class TmuxOutput extends Tmux { $buffer = ''; $state = ((int) $this->runVar['settings']['is_running'] === 1) ? 'Running' : 'Disabled'; - $version = Process::run('git describe --tags')->output(); - $branch = Process::run('git branch')->output(); + $version = str_replace(["\n", "\r"], '', Process::run('git describe --tags')->output()); + $branch = str_replace(["\n", "\r"], '', Process::run('git branch --show-current')->output()); $buffer .= sprintf( $this->tmpMasks[2], diff --git a/Blacklight/libraries/Forking.php b/Blacklight/libraries/Forking.php index 5c954b52d..93662ff1c 100755 --- a/Blacklight/libraries/Forking.php +++ b/Blacklight/libraries/Forking.php @@ -12,7 +12,7 @@ use Blacklight\processing\PostProcess; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; -use Illuminate\Support\Facades\Process; +use Symfony\Component\Process\Process; use Opis\Closure\SerializableClosure; use Spatie\Async\Output\SerializableException; use Spatie\Async\Pool; @@ -910,11 +910,20 @@ class Forking //////////////////////////////////////////// Various methods /////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - protected function _executeCommand(string $command): void + /** + * @param string $command + * @return string + */ + protected function _executeCommand(string $command): string { - Process::timeout(config('nntmux.multiprocessing_max_child_time'))->run($command, function (string $type, string $output) { - echo $output; + $process = Process::fromShellCommandline($command); + $process->setTimeout(1800); + $process->run(function ($type, $buffer) { + if (Process::ERR === $type) { + echo $buffer; + } }); + return $process->getOutput(); } /** diff --git a/app/Console/Commands/TmuxUIStart.php b/app/Console/Commands/TmuxUIStart.php index 7a09fd47a..9764c39f8 100644 --- a/app/Console/Commands/TmuxUIStart.php +++ b/app/Console/Commands/TmuxUIStart.php @@ -38,7 +38,7 @@ class TmuxUIStart extends Command $session = Process::run("tmux list-session | grep $tmux_session"); if ($session->exitCode() === 1) { $this->info('Starting the tmux server and monitor script'); - Process::forever()->tty()->run('php '.app()->/* @scrutinizer ignore-call */ path().'/../misc/update/tmux/run.php'); + Process::forever()->run('php '.app()->/* @scrutinizer ignore-call */ path().'/../misc/update/tmux/run.php'); } } }