From 3eb628b77304fc7c192cab5dc8fed5221e8118b8 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Tue, 26 Sep 2023 15:07:33 +0200 Subject: [PATCH] fix: containerstatusjob --- app/Http/Livewire/Project/Service/Index.php | 2 ++ app/Jobs/ContainerStatusJob.php | 4 ++-- app/Models/Service.php | 10 +++++++--- app/Models/ServiceApplication.php | 6 ------ app/Models/ServiceDatabase.php | 4 ---- .../livewire/project/service/application.blade.php | 1 - .../views/livewire/project/service/database.blade.php | 1 - .../views/livewire/project/service/index.blade.php | 4 +++- 8 files changed, 14 insertions(+), 18 deletions(-) diff --git a/app/Http/Livewire/Project/Service/Index.php b/app/Http/Livewire/Project/Service/Index.php index 88d8679bc..827175bb2 100644 --- a/app/Http/Livewire/Project/Service/Index.php +++ b/app/Http/Livewire/Project/Service/Index.php @@ -2,6 +2,7 @@ namespace App\Http\Livewire\Project\Service; +use App\Jobs\ContainerStatusJob; use App\Models\Service; use DanHarrin\LivewireRateLimiting\WithRateLimiting; use Livewire\Component; @@ -23,6 +24,7 @@ class Index extends Component public function manualRefreshStack() { try { $this->rateLimit(5); + dispatch_sync(new ContainerStatusJob($this->service->server)); $this->refreshStack(); } catch(\Throwable $e) { return handleError($e, $this); diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 0cfd9b373..6fe26498e 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -74,7 +74,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted $containers = format_docker_command_output_to_json($containers); $applications = $this->server->applications(); $databases = $this->server->databases(); - $services = $this->server->services(); + $services = $this->server->services()->get(); $previews = $this->server->previews(); $this->server->proxyType(); /// Check if proxy is running @@ -170,7 +170,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted } } $exitedServices = collect([]); - foreach ($services->get() as $service) { + foreach ($services as $service) { $apps = $service->applications()->get(); $dbs = $service->databases()->get(); foreach ($apps as $app) { diff --git a/app/Models/Service.php b/app/Models/Service.php index bf44b8264..e6f1acf8a 100644 --- a/app/Models/Service.php +++ b/app/Models/Service.php @@ -5,6 +5,7 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Cache; use Symfony\Component\Yaml\Yaml; use Illuminate\Support\Str; use Spatie\Url\Url; @@ -47,6 +48,12 @@ class Service extends BaseModel return 'service'; } + public function documentation() + { + $services = Cache::get('services', []); + $service = data_get($services, Str::of($this->name)->beforeLast('-')->value, []); + return data_get($service, 'documentation', 'https://coolify.io/docs'); + } public function applications() { return $this->hasMany(ServiceApplication::class); @@ -137,8 +144,6 @@ class Service extends BaseModel if (!$requiredFqdns) { $requiredFqdns = collect([]); } - ray('parsing'); - // ray()->clearAll(); if ($this->docker_compose_raw) { try { $yaml = Yaml::parse($this->docker_compose_raw); @@ -513,7 +518,6 @@ class Service extends BaseModel $number = 0; } $fqdn = getFqdnWithoutPort(data_get($fqdns, $number, $fqdns->first())); - ray($fqdns); $environments = collect(data_get($service, 'environment')); $environments = $environments->map(function ($envValue) use ($value, $fqdn) { $envValue = Str::of($envValue)->replace($value, $fqdn); diff --git a/app/Models/ServiceApplication.php b/app/Models/ServiceApplication.php index e7bb84d68..91bfc7d78 100644 --- a/app/Models/ServiceApplication.php +++ b/app/Models/ServiceApplication.php @@ -14,12 +14,6 @@ class ServiceApplication extends BaseModel { return 'service'; } - public function documentation() - { - $services = Cache::get('services', []); - $service = data_get($services, $this->name, []); - return data_get($service, 'documentation', 'https://coolify.io/docs'); - } public function service() { return $this->belongsTo(Service::class); diff --git a/app/Models/ServiceDatabase.php b/app/Models/ServiceDatabase.php index 86184ff50..09b216219 100644 --- a/app/Models/ServiceDatabase.php +++ b/app/Models/ServiceDatabase.php @@ -14,10 +14,6 @@ class ServiceDatabase extends BaseModel { return 'service'; } - public function documentation() - { - return data_get(Yaml::parse($this->service->docker_compose_raw), "services.{$this->name}.documentation", 'https://coolify.io/docs'); - } public function service() { return $this->belongsTo(Service::class); diff --git a/resources/views/livewire/project/service/application.blade.php b/resources/views/livewire/project/service/application.blade.php index 5c26c950b..d9c0a5f30 100644 --- a/resources/views/livewire/project/service/application.blade.php +++ b/resources/views/livewire/project/service/application.blade.php @@ -8,7 +8,6 @@ @endif Save Delete - Documentation
diff --git a/resources/views/livewire/project/service/database.blade.php b/resources/views/livewire/project/service/database.blade.php index fbde06a74..6bc2c06dd 100644 --- a/resources/views/livewire/project/service/database.blade.php +++ b/resources/views/livewire/project/service/database.blade.php @@ -7,7 +7,6 @@

{{ Str::headline($database->name) }}

@endif Save - Documentation
diff --git a/resources/views/livewire/project/service/index.blade.php b/resources/views/livewire/project/service/index.blade.php index b2fc8c422..d19e492a3 100644 --- a/resources/views/livewire/project/service/index.blade.php +++ b/resources/views/livewire/project/service/index.blade.php @@ -2,6 +2,7 @@
+ Documentation Service Stack @@ -21,6 +22,7 @@

Configuration

Save +
Str::of( $application->status)->contains(['running']), 'border-l border-dashed border-warning' => Str::of( - $application->status)->contains(['restarting']), + $application->status)->contains(['starting']), 'flex flex-col justify-center box', ]) href="{{ route('project.service.show', [...$parameters, 'service_name' => $application->name]) }}">