Refactoring: extract process handling from async job.

This commit is contained in:
Joao Patricio
2023-03-21 09:31:16 +00:00
parent be351232d3
commit d0d33da493
5 changed files with 15 additions and 18 deletions

View File

@@ -23,21 +23,21 @@ class RunCommand extends Component
{
$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(<<<EOT
$this->activity = remoteProcess(<<<EOT
cd projects/dummy-project
~/.docker/cli-plugins/docker-compose build --no-cache
EOT, 'testing-host');

View File

@@ -7,7 +7,6 @@ use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Process\ProcessResult;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Spatie\Activitylog\Contracts\Activity;

View File

@@ -3,7 +3,6 @@
namespace App\Services;
use App\Jobs\ExecuteCoolifyProcess;
use Illuminate\Process\ProcessResult;
use Spatie\Activitylog\Contracts\Activity;
class CoolifyProcess
@@ -36,8 +35,11 @@ class CoolifyProcess
dispatch($job);
$this->activity->refresh();
ray($this->activity->id);
return $this->activity;
}
}