mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-02 22:46:16 +00:00
2.x - php
This commit is contained in:
@ -2,11 +2,13 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Exception;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
/**
|
||||
* @property int $server_id
|
||||
@ -46,7 +48,7 @@ public static function boot(): void
|
||||
if (Storage::disk($log->disk)->exists($log->name)) {
|
||||
Storage::disk($log->disk)->delete($log->name);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
Log::error($e->getMessage(), ['exception' => $e]);
|
||||
}
|
||||
});
|
||||
@ -67,6 +69,11 @@ public function site(): BelongsTo
|
||||
return $this->belongsTo(Site::class);
|
||||
}
|
||||
|
||||
public function download(): StreamedResponse
|
||||
{
|
||||
return Storage::disk($this->disk)->download($this->name);
|
||||
}
|
||||
|
||||
public static function getRemote($query, bool $active = true, ?Site $site = null)
|
||||
{
|
||||
$query->where('is_remote', $active);
|
||||
|
@ -3,6 +3,7 @@
|
||||
namespace App\Models;
|
||||
|
||||
use App\Actions\Service\Manage;
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Exceptions\ServiceInstallationFailed;
|
||||
use App\SSH\Services\ServiceInterface;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
@ -54,6 +55,21 @@ public static function boot(): void
|
||||
});
|
||||
}
|
||||
|
||||
public static array $statusColors = [
|
||||
ServiceStatus::READY => 'success',
|
||||
ServiceStatus::INSTALLING => 'warning',
|
||||
ServiceStatus::INSTALLATION_FAILED => 'danger',
|
||||
ServiceStatus::UNINSTALLING => 'warning',
|
||||
ServiceStatus::FAILED => 'danger',
|
||||
ServiceStatus::STARTING => 'warning',
|
||||
ServiceStatus::STOPPING => 'warning',
|
||||
ServiceStatus::RESTARTING => 'warning',
|
||||
ServiceStatus::STOPPED => 'danger',
|
||||
ServiceStatus::ENABLING => 'warning',
|
||||
ServiceStatus::DISABLING => 'warning',
|
||||
ServiceStatus::DISABLED => 'gray',
|
||||
];
|
||||
|
||||
public function server(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Server::class);
|
||||
@ -72,7 +88,7 @@ public function handler(): ServiceInterface
|
||||
public function validateInstall($result): void
|
||||
{
|
||||
if (! Str::contains($result, 'Active: active')) {
|
||||
throw new ServiceInstallationFailed();
|
||||
throw new ServiceInstallationFailed;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user