Skip to content

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.

Refactoring: extract process handling from async job.

Joao Patricio34c9265aa9f6
diff --git a/app/Actions/RemoteProcess/DispatchRemoteProcess.php b/app/Actions/RemoteProcess/DispatchRemoteProcess.php
index c8a81699a2..09dc2348e2 100644
--- a/app/Actions/RemoteProcess/DispatchRemoteProcess.php
+++ b/app/Actions/RemoteProcess/DispatchRemoteProcess.php
@@ -2,6 +2,7 @@
namespace App\Actions\RemoteProcess;
+use App\Data\RemoteProcessArgs;
use App\Enums\ActivityTypes;
use App\Enums\ProcessStatus;
use App\Jobs\ExecuteCoolifyProcess;
@@ -19,15 +20,15 @@ class DispatchRemoteProcess
protected ?int $port = 22,
protected ?string $user = 'root',
){
+ $arguments = new RemoteProcessArgs(
+ destination: $this->destination,
+ command: $this->command,
+ port: $this->port,
+ user: $this->user,
+ );
+
$this->activity = activity()
- ->withProperties([
- 'type' => ActivityTypes::COOLIFY_PROCESS,
- 'status' => ProcessStatus::HOLDING,
- 'user' => $this->user,
- 'destination' => $this->destination,
- 'port' => $this->port,
- 'command' => $this->command,
- ])
+ ->withProperties($arguments->toArray())
->log("Awaiting command to start...\n\n");
}
diff --git a/app/Data/RemoteProcessArgs.php b/app/Data/RemoteProcessArgs.php
new file mode 100644
index 0000000000..a94e461fb6
--- /dev/null
+++ b/app/Data/RemoteProcessArgs.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Data;
+
+use App\Enums\ActivityTypes;
+use App\Enums\ProcessStatus;
+use Spatie\LaravelData\Data;
+
+class RemoteProcessArgs extends Data
+{
+ public function __construct(
+ protected string $destination,
+ protected string $command,
+ protected int $port = 22,
+ protected string $user = 'root',
+ protected string $type = ActivityTypes::COOLIFY_PROCESS->value,
+ protected string $status = ProcessStatus::HOLDING->value,
+ ){}
+}
diff --git a/composer.json b/composer.json
index 2b626323e3..b023863bc9 100644
--- a/composer.json
+++ b/composer.json
@@ -5,7 +5,7 @@
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
- "php": "^8.1",
+ "php": "^8.2",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.0",
"laravel/sanctum": "^3.2",