use blade as conmmands template (#444)

* use blade as conmmands template

* fix lint

* fix ssl
This commit is contained in:
Saeed Vaziry
2025-01-27 21:27:58 +01:00
committed by GitHub
parent a73476c1dd
commit cdbde063f0
208 changed files with 1080 additions and 1012 deletions

View File

@ -5,11 +5,7 @@
use App\Actions\Service\Manage;
use App\Enums\ServiceStatus;
use App\Exceptions\ServiceInstallationFailed;
use App\SSH\Services\Database\Database as DatabaseAlias;
use App\SSH\Services\PHP\PHP as PHPAlias;
use App\SSH\Services\ProcessManager\ProcessManager;
use App\SSH\Services\ServiceInterface;
use App\SSH\Services\WebServer\WebServer as WebServerAlias;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
@ -79,9 +75,6 @@ public function server(): BelongsTo
return $this->belongsTo(Server::class);
}
/**
* @return ProcessManager|DatabaseAlias|PHPAlias|WebServerAlias
*/
public function handler(): ServiceInterface
{
$handler = config('core.service_handlers')[$this->name];

View File

@ -3,6 +3,7 @@
namespace App\Models;
use App\Enums\SiteStatus;
use App\Enums\SslStatus;
use App\Exceptions\FailedToDestroyGitHook;
use App\Exceptions\SourceControlIsNotConnected;
use App\Exceptions\SSHError;
@ -35,6 +36,7 @@
* @property int $port
* @property int $progress
* @property string $user
* @property bool $force_ssl
* @property Server $server
* @property ServerLog[] $logs
* @property Deployment[] $deployments
@ -198,6 +200,9 @@ public function php(): ?Service
return null;
}
/**
* @throws SSHError
*/
public function changePHPVersion($version): void
{
/** @var Webserver $handler */
@ -219,6 +224,7 @@ public function activeSsl(): HasOne
{
return $this->hasOne(Ssl::class)
->where('expires_at', '>=', now())
->where('status', SslStatus::CREATED)
->orderByDesc('id');
}
@ -301,11 +307,6 @@ public function getEnv(): string
}
}
public function hasSSL(): bool
{
return $this->ssls->isNotEmpty();
}
public function environmentVariables(?Deployment $deployment = null): array
{
return [
@ -319,30 +320,16 @@ public function environmentVariables(?Deployment $deployment = null): array
];
}
public function isolate(): void
{
if (! $this->isIsolated()) {
return;
}
$this->server->os()->createIsolatedUser(
$this->user,
Str::random(15),
$this->id
);
// Generate the FPM pool
/** @var PHP $php */
$php = $this->php()->handler();
$php->createFpmPool(
$this->user,
$this->php_version,
$this->id
);
}
public function isIsolated(): bool
{
return $this->user != $this->server->getSshUser();
}
public function webserver(): Webserver
{
/** @var Webserver $webserver */
$webserver = $this->server->webserver()->handler();
return $webserver;
}
}