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.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix: service status check fix: containerStatusJob fix: service form
Andras Bacsai9318cac1899f
diff --git a/app/Http/Livewire/Project/Service/Index.php b/app/Http/Livewire/Project/Service/Index.phpindex 687732540c..fba473250f 100644--- a/app/Http/Livewire/Project/Service/Index.php+++ b/app/Http/Livewire/Project/Service/Index.php@@ -13,13 +13,7 @@ class Index extends Componentpublic $databases;public array $parameters;public array $query;- protected $rules = [- 'service.docker_compose_raw' => 'required',- 'service.docker_compose' => 'required',- 'service.name' => 'required',- 'service.description' => 'nullable',- ];- protected $listeners = ["saveCompose"];+ protected $listeners = ["refreshStacks","checkStatus"];public function render(){return view('livewire.project.service.index');@@ -32,17 +26,12 @@ class Index extends Component$this->applications = $this->service->applications->sort();$this->databases = $this->service->databases->sort();}- public function saveCompose($raw)- {- $this->service->docker_compose_raw = $raw;- $this->submit();- }public function checkStatus(){dispatch_sync(new ContainerStatusJob($this->service->server));- $this->refreshStack();+ $this->refreshStacks();}- public function refreshStack()+ public function refreshStacks(){$this->applications = $this->service->applications->sort();$this->applications->each(function ($application) {@@ -53,21 +42,4 @@ class Index extends Component$database->refresh();});}--- public function submit()- {- try {- $this->validate();- $this->service->save();- $this->service->parse();- $this->service->refresh();- $this->service->saveComposeConfigs();- $this->refreshStack();- $this->emit('refreshEnvs');- $this->emit('success', 'Service saved successfully.');- } catch (\Throwable $e) {- return handleError($e, $this);- }- }}diff --git a/app/Http/Livewire/Project/Service/Modal.php b/app/Http/Livewire/Project/Service/Modal.phpindex a5fd759e79..7092070f64 100644--- a/app/Http/Livewire/Project/Service/Modal.php+++ b/app/Http/Livewire/Project/Service/Modal.php@@ -6,8 +6,8 @@ use Livewire\Component;class Modal extends Component{- public function serviceStatusUpdated() {- $this->emit('serviceStatusUpdated');+ public function checkStatus() {+ $this->emit('checkStatus');}public function render(){diff --git a/app/Http/Livewire/Project/Service/Navbar.php b/app/Http/Livewire/Project/Service/Navbar.phpindex 3f7679c561..d85c6f4356 100644--- a/app/Http/Livewire/Project/Service/Navbar.php+++ b/app/Http/Livewire/Project/Service/Navbar.php@@ -13,20 +13,15 @@ class Navbar extends Componentpublic Service $service;public array $parameters;public array $query;- protected $listeners = ['serviceStatusUpdated'];public function render(){return view('livewire.project.service.navbar');}- public function serviceStatusUpdated()- {- $this->check_status();- }- public function check_status()++ public function checkStatus(){- dispatch_sync(new ContainerStatusJob($this->service->server));- $this->service->refresh();+ $this->emit('checkStatus');}public function deploy(){diff --git a/app/Http/Livewire/Project/Service/StackForm.php b/app/Http/Livewire/Project/Service/StackForm.phpnew file mode 100644index 0000000000..1518e3d225--- /dev/null+++ b/app/Http/Livewire/Project/Service/StackForm.php@@ -0,0 +1,42 @@+<?php++namespace App\Http\Livewire\Project\Service;++use Livewire\Component;++class StackForm extends Component+{+ protected $listeners = ["saveCompose"];+ protected $rules = [+ 'service.docker_compose_raw' => 'required',+ 'service.docker_compose' => 'required',+ 'service.name' => 'required',+ 'service.description' => 'nullable',+ ];+ public $service;+ public function saveCompose($raw)+ {+ $this->service->docker_compose_raw = $raw;+ $this->submit();+ }++ public function submit()+ {+ try {+ $this->validate();+ $this->service->save();+ $this->service->parse();+ $this->service->refresh();+ $this->service->saveComposeConfigs();+ $this->emit('refreshStacks');+ $this->emit('refreshEnvs');+ $this->emit('success', 'Service saved successfully.');+ } catch (\Throwable $e) {+ return handleError($e, $this);+ }+ }+ public function render()+ {+ return view('livewire.project.service.stack-form');+ }+}diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.phpindex 392819440f..9b4ef56994 100644--- a/app/Jobs/ContainerStatusJob.php+++ b/app/Jobs/ContainerStatusJob.php@@ -29,7 +29,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncryptedpublic function __construct(public Server $server){- $this->handle();+}public function middleware(): array@@ -44,7 +44,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncryptedpublic function handle(){try {- ray("checking server status for {$this->server->name}");+ ray("checking server status for {$this->server->id}");// ray()->clearAll();$serverUptimeCheckNumber = $this->server->unreachable_count;$serverUptimeCheckNumberMax = 3;diff --git a/resources/views/livewire/project/service/index.blade.php b/resources/views/livewire/project/service/index.blade.phpindex 05a90dd5de..a966c56d4d 100644--- a/resources/views/livewire/project/service/index.blade.php+++ b/resources/views/livewire/project/service/index.blade.php@@ -1,40 +1,24 @@-<div x-data="{ raw: true, activeTab: window.location.hash ? window.location.hash.substring(1) : 'service-stack' }" wire:poll.10000ms="checkStatus">+<div x-data="{ raw: true, activeTab: window.location.hash ? window.location.hash.substring(1) : 'service-stack' }" wire:poll.15000ms="checkStatus"><livewire:project.service.navbar :service="$service" :parameters="$parameters" :query="$query" /><livewire:project.service.compose-modal :raw="$service->docker_compose_raw" :actual="$service->docker_compose" /><div class="flex h-full pt-6"><div class="flex flex-col items-start gap-4 min-w-fit"><a target="_blank" href="{{ $service->documentation() }}">Documentation <x-external-link /></a>- <a :class="activeTab === 'service-stack' && 'text-white'"- @click.prevent="activeTab = 'service-stack'; window.location.hash = 'service-stack'"- href="#">Service Stack</a>- <a :class="activeTab === 'storages' && 'text-white'"- @click.prevent="activeTab = 'storages'; window.location.hash = 'storages'" href="#">Storages</a>+ <a :class="activeTab === 'service-stack' && 'text-white'" @click.prevent="activeTab = 'service-stack';+ window.location.hash = 'service-stack'" href="#">Service Stack</a>+ <a :class="activeTab === 'storages' && 'text-white'" @click.prevent="activeTab = 'storages';+ window.location.hash = 'storages'" href="#">Storages</a><a :class="activeTab === 'environment-variables' && 'text-white'"@click.prevent="activeTab = 'environment-variables'; window.location.hash = 'environment-variables'"href="#">EnvironmentVariables</a>- <a :class="activeTab === 'danger' && 'text-white'"- @click.prevent="activeTab = 'danger'; window.location.hash = 'danger'" href="#">Danger Zone+ <a :class="activeTab === 'danger' && 'text-white'" @click.prevent="activeTab = 'danger';+ window.location.hash = 'danger'" href="#">Danger Zone</a></div><div class="w-full pl-8"><div x-cloak x-show="activeTab === 'service-stack'">- <form wire:submit.prevent='submit' class="flex flex-col gap-4 pb-2">- <div class="flex gap-2">- <div>- <h2> Service Stack </h2>- <div>Configuration</div>- </div>- <x-forms.button type="submit">Save</x-forms.button>- <x-forms.button class="w-64" onclick="composeModal.showModal()">Edit Compose- File</x-forms.button>- </div>- <div class="flex gap-2">- <x-forms.input id="service.name" required label="Service Name"- placeholder="My super wordpress site" />- <x-forms.input id="service.description" label="Description" />- </div>- </form>+ <livewire:project.service.stack-form :service="$service" /><div class="grid grid-cols-1 gap-2 pt-4 xl:grid-cols-3">@foreach ($applications as $application)<div @class([@@ -66,7 +50,8 @@<div class="text-xs">{{ $application->status }}</div></a><a class="flex gap-2 p-1 mx-4 font-bold rounded group-hover:text-white hover:no-underline"- href="{{ route('project.service.logs', [...$parameters, 'service_name' => $application->name]) }}"><span class="hover:text-warning">Logs</span></a>+ href="{{ route('project.service.logs', [...$parameters, 'service_name' => $application->name]) }}"><span+ class="hover:text-warning">Logs</span></a></div>@endforeach@foreach ($databases as $database)@@ -95,7 +80,8 @@<div class="text-xs">{{ $database->status }}</div></a><a class="flex gap-2 p-1 mx-4 font-bold rounded hover:no-underline group-hover:text-white"- href="{{ route('project.service.logs', [...$parameters, 'service_name' => $database->name]) }}"><span class="hover:text-warning">Logs</span></a>+ href="{{ route('project.service.logs', [...$parameters, 'service_name' => $database->name]) }}"><span+ class="hover:text-warning">Logs</span></a></div>@endforeach</div>@@ -126,3 +112,4 @@</div></div></div>+</div>diff --git a/resources/views/livewire/project/service/modal.blade.php b/resources/views/livewire/project/service/modal.blade.phpindex 8517d3ef16..2333379d06 100644--- a/resources/views/livewire/project/service/modal.blade.php+++ b/resources/views/livewire/project/service/modal.blade.php@@ -1,5 +1,5 @@<div>- <x-modal submitWireAction="serviceStatusUpdated" modalId="startService">+ <x-modal submitWireAction="checkStatus" modalId="startService"><x-slot:modalBody><livewire:activity-monitor header="Service Startup Logs" /></x-slot:modalBody>diff --git a/resources/views/livewire/project/service/navbar.blade.php b/resources/views/livewire/project/service/navbar.blade.phpindex d18838ccef..0825c2c7f6 100644--- a/resources/views/livewire/project/service/navbar.blade.php+++ b/resources/views/livewire/project/service/navbar.blade.php@@ -1,4 +1,4 @@-<div x-init="$wire.check_status">+<div x-init="$wire.checkStatus"><livewire:project.service.modal /><h1>Configuration</h1><x-resources.breadcrumbs :resource="$service" :parameters="$parameters" />diff --git a/resources/views/livewire/project/service/stack-form.blade.php b/resources/views/livewire/project/service/stack-form.blade.phpnew file mode 100644index 0000000000..7225770c1f--- /dev/null+++ b/resources/views/livewire/project/service/stack-form.blade.php@@ -0,0 +1,16 @@+<form wire:submit.prevent='submit' class="flex flex-col gap-4 pb-2">+ <div class="flex gap-2">+ <div>+ <h2>Service Stack</h2>+ <div>Configuration</div>+ </div>+ <x-forms.button type="submit">Save</x-forms.button>+ <x-forms.button class="w-64" onclick="composeModal.showModal()">Edit Compose+ File</x-forms.button>+ </div>+ <div class="flex gap-2">+ <x-forms.input id="service.name" required label="Service Name"+ placeholder="My super wordpress site" />+ <x-forms.input id="service.description" label="Description" />+ </div>+</form>