diff --git a/app/Http/Livewire/RunCommand.php b/app/Http/Livewire/RunCommand.php index 76425e012..ae189422e 100755 --- a/app/Http/Livewire/RunCommand.php +++ b/app/Http/Livewire/RunCommand.php @@ -23,21 +23,21 @@ public function runCommand() { $this->isKeepAliveOn = true; - $this->activity = coolifyProcess($this->command, 'testing-host'); + $this->activity = remoteProcess($this->command, 'testing-host'); } public function runSleepingBeauty() { $this->isKeepAliveOn = true; - $this->activity = coolifyProcess('x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', 'testing-host'); + $this->activity = remoteProcess('x=1; while [ $x -le 40 ]; do sleep 0.1 && echo "Welcome $x times" $(( x++ )); done', 'testing-host'); } public function runDummyProjectBuild() { $this->isKeepAliveOn = true; - $this->activity = coolifyProcess(<<activity = remoteProcess(<<activity->refresh(); + + ray($this->activity->id); + return $this->activity; } - } diff --git a/bootstrap/helpers.php b/bootstrap/helpers.php index 4d26314f2..e4d1f51a7 100644 --- a/bootstrap/helpers.php +++ b/bootstrap/helpers.php @@ -3,21 +3,17 @@ use App\Services\CoolifyProcess; use Spatie\Activitylog\Contracts\Activity; -if (! function_exists('coolifyProcess')) { +if (! function_exists('remoteProcess')) { /** * Run a Coolify Process, which SSH's into a machine to run the command(s). * */ - function coolifyProcess($command, $destination): Activity + function remoteProcess($command, $destination): Activity { - $process = resolve(CoolifyProcess::class, [ + return resolve(CoolifyProcess::class, [ 'destination' => $destination, 'command' => $command, - ]); - - $activityLog = $process(); - - return $activityLog; + ])(); } } diff --git a/tests/Feature/DockerCommandsTest.php b/tests/Feature/DockerCommandsTest.php index 45a2f1f64..918025525 100644 --- a/tests/Feature/DockerCommandsTest.php +++ b/tests/Feature/DockerCommandsTest.php @@ -13,21 +13,21 @@ $host = 'testing-host'; // Assert there's no containers start with coolify_test_* - $activity = coolifyProcess($areThereCoolifyTestContainers, $host); + $activity = remoteProcess($areThereCoolifyTestContainers, $host); ray($activity); $containers = Output::containerList($activity->getExtraProperty('stdout')); expect($containers)->toBeEmpty(); // start a container nginx -d --name = $containerName - $activity = coolifyProcess("docker run -d --name {$containerName} nginx", $host); + $activity = remoteProcess("docker run -d --name {$containerName} nginx", $host); expect($activity->getExtraProperty('exitCode'))->toBe(0); // docker ps name = $container - $activity = coolifyProcess($areThereCoolifyTestContainers, $host); + $activity = remoteProcess($areThereCoolifyTestContainers, $host); $containers = Output::containerList($activity->getExtraProperty('stdout')); expect($containers->where('Names', $containerName)->count())->toBe(1); // Stop testing containers - $activity = coolifyProcess("docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -q)", $host); + $activity = remoteProcess("docker stop $(docker ps --filter='name={$coolifyNamePrefix}*' -q)", $host); expect($activity->getExtraProperty('exitCode'))->toBe(0); });