This commit is contained in:
2025-04-07 12:16:11 +01:00
parent ce8b201a1c
commit e15a80163b
62 changed files with 149 additions and 131 deletions

View File

@@ -9,7 +9,7 @@ use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Spatie\Ssh\Ssh;
class ProvisionServer implements ShouldQueue, ShouldBeEncrypted
class ProvisionServer implements ShouldBeEncrypted, ShouldQueue
{
use Queueable;
@@ -37,7 +37,7 @@ class ProvisionServer implements ShouldQueue, ShouldBeEncrypted
// Download the provision script and execute it
// The script will run in the background
$result = $ssh->execute([
'wget --quiet --output-document=provision.sh "' . $provisionScriptUrl . '"',
'wget --quiet --output-document=provision.sh "'.$provisionScriptUrl.'"',
'chmod +x provision.sh',
'nohup ./provision.sh > /dev/null 2>&1 &',
]);
@@ -46,6 +46,7 @@ class ProvisionServer implements ShouldQueue, ShouldBeEncrypted
$this->server->update([
'status' => ServerStatus::PROVISIONING_FAILED,
]);
return;
}

View File

@@ -7,14 +7,14 @@ use App\Models\Server;
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Illuminate\Support\Str;
use Spatie\Ssh\Ssh;
class WaitForServerToConnect implements ShouldQueue, ShouldBeEncrypted
class WaitForServerToConnect implements ShouldBeEncrypted, ShouldQueue
{
use Queueable;
public int $retryAfter = 15;
public int $tries = 40;
public function __construct(
@@ -35,6 +35,7 @@ class WaitForServerToConnect implements ShouldQueue, ShouldBeEncrypted
if (! $process->isSuccessful()) {
$this->release(15);
return;
}

View File

@@ -18,8 +18,7 @@ class DeployService implements ShouldQueue
public function __construct(
public Service $service,
public ?string $defaultPassword = null,
)
{
) {
//
}
@@ -27,7 +26,7 @@ class DeployService implements ShouldQueue
{
$driver = $this->service->driver($this->defaultPassword);
$this->service->update([
'status' => ServiceStatus::INSTALLING
'status' => ServiceStatus::INSTALLING,
]);
$this->deployment = $this->service->deployments()->create([
'status' => DeploymentStatus::PENDING,

View File

@@ -7,7 +7,6 @@ use App\Enums\ServiceStatus;
use App\Models\Step;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
use Spatie\Ssh\Ssh;
class RunStep implements ShouldQueue
{
@@ -15,8 +14,7 @@ class RunStep implements ShouldQueue
public function __construct(
protected Step $step,
)
{
) {
//
}
@@ -33,7 +31,7 @@ class RunStep implements ShouldQueue
$ssh = $server->sshClient()
->onOutput(function ($output) {
$this->step->update([
'logs' => $this->step->logs . "\n" . trim($output),
'logs' => $this->step->logs."\n".trim($output),
]);
});
@@ -43,7 +41,7 @@ class RunStep implements ShouldQueue
$this->step->update([
'status' => DeploymentStatus::FAILED,
'finished_at' => now(),
'logs' => $this->step->logs . "\n" . trim($result->getErrorOutput()),
'logs' => $this->step->logs."\n".trim($result->getErrorOutput()),
]);
return;
@@ -74,7 +72,7 @@ class RunStep implements ShouldQueue
$this->step->update([
'status' => DeploymentStatus::FAILED,
'finished_at' => now(),
'logs' => $this->step->logs . "\n" . trim($exception->getMessage()),
'logs' => $this->step->logs."\n".trim($exception->getMessage()),
]);
$this->step->deployment->steps()->where('order', '>', $this->step->order)->update([