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(database): honor disabled standalone health checks
Andras Bacsai51062e73a6f9
diff --git a/app/Actions/Database/StartClickhouse.php b/app/Actions/Database/StartClickhouse.phpindex 1128b8f8fb..525e736c36 100644--- a/app/Actions/Database/StartClickhouse.php+++ b/app/Actions/Database/StartClickhouse.php@@ -50,13 +50,9 @@ class StartClickhouse],],'labels' => defaultDatabaseLabels($this->database)->toArray(),- 'healthcheck' => [- 'test' => ['CMD', 'clickhouse-client', '--user', (string) $this->database->clickhouse_admin_user, '--password', (string) $this->database->clickhouse_admin_password, '--query', 'SELECT 1'],- 'interval' => "{$this->database->health_check_interval}s",- 'timeout' => "{$this->database->health_check_timeout}s",- 'retries' => $this->database->health_check_retries,- 'start_period' => "{$this->database->health_check_start_period}s",- ],+ 'healthcheck' => $this->database->healthCheckConfiguration([+ 'CMD', 'clickhouse-client', '--user', (string) $this->database->clickhouse_admin_user, '--password', (string) $this->database->clickhouse_admin_password, '--query', 'SELECT 1',+ ]),'mem_limit' => $this->database->limits_memory,'memswap_limit' => $this->database->limits_memory_swap,'mem_swappiness' => $this->database->limits_memory_swappiness,diff --git a/app/Actions/Database/StartDragonfly.php b/app/Actions/Database/StartDragonfly.phpindex 530ba7d238..b78a0987d9 100644--- a/app/Actions/Database/StartDragonfly.php+++ b/app/Actions/Database/StartDragonfly.php@@ -106,13 +106,9 @@ class StartDragonfly$this->database->destination->network,],'labels' => defaultDatabaseLabels($this->database)->toArray(),- 'healthcheck' => [- 'test' => ['CMD', 'redis-cli', '-a', (string) $this->database->dragonfly_password, 'ping'],- 'interval' => "{$this->database->health_check_interval}s",- 'timeout' => "{$this->database->health_check_timeout}s",- 'retries' => $this->database->health_check_retries,- 'start_period' => "{$this->database->health_check_start_period}s",- ],+ 'healthcheck' => $this->database->healthCheckConfiguration([+ 'CMD', 'redis-cli', '-a', (string) $this->database->dragonfly_password, 'ping',+ ]),'mem_limit' => $this->database->limits_memory,'memswap_limit' => $this->database->limits_memory_swap,'mem_swappiness' => $this->database->limits_memory_swappiness,diff --git a/app/Actions/Database/StartKeydb.php b/app/Actions/Database/StartKeydb.phpindex e9acd0b3c8..89258fe249 100644--- a/app/Actions/Database/StartKeydb.php+++ b/app/Actions/Database/StartKeydb.php@@ -108,13 +108,9 @@ class StartKeydb$this->database->destination->network,],'labels' => defaultDatabaseLabels($this->database)->toArray(),- 'healthcheck' => [- 'test' => ['CMD', 'keydb-cli', '--pass', (string) $this->database->keydb_password, 'ping'],- 'interval' => "{$this->database->health_check_interval}s",- 'timeout' => "{$this->database->health_check_timeout}s",- 'retries' => $this->database->health_check_retries,- 'start_period' => "{$this->database->health_check_start_period}s",- ],+ 'healthcheck' => $this->database->healthCheckConfiguration([+ 'CMD', 'keydb-cli', '--pass', (string) $this->database->keydb_password, 'ping',+ ]),'mem_limit' => $this->database->limits_memory,'memswap_limit' => $this->database->limits_memory_swap,'mem_swappiness' => $this->database->limits_memory_swappiness,diff --git a/app/Actions/Database/StartMariadb.php b/app/Actions/Database/StartMariadb.phpindex 17ed2a9a89..2e8faea9a3 100644--- a/app/Actions/Database/StartMariadb.php+++ b/app/Actions/Database/StartMariadb.php@@ -103,13 +103,9 @@ class StartMariadb$this->database->destination->network,],'labels' => defaultDatabaseLabels($this->database)->toArray(),- 'healthcheck' => [- 'test' => ['CMD', 'healthcheck.sh', '--connect', '--innodb_initialized'],- 'interval' => "{$this->database->health_check_interval}s",- 'timeout' => "{$this->database->health_check_timeout}s",- 'retries' => $this->database->health_check_retries,- 'start_period' => "{$this->database->health_check_start_period}s",- ],+ 'healthcheck' => $this->database->healthCheckConfiguration([+ 'CMD', 'healthcheck.sh', '--connect', '--innodb_initialized',+ ]),'mem_limit' => $this->database->limits_memory,'memswap_limit' => $this->database->limits_memory_swap,'mem_swappiness' => $this->database->limits_memory_swappiness,diff --git a/app/Actions/Database/StartMongodb.php b/app/Actions/Database/StartMongodb.phpindex e5973e8071..80ec812a1f 100644--- a/app/Actions/Database/StartMongodb.php+++ b/app/Actions/Database/StartMongodb.php@@ -109,17 +109,11 @@ class StartMongodb$this->database->destination->network,],'labels' => defaultDatabaseLabels($this->database)->toArray(),- 'healthcheck' => [- 'test' => [- 'CMD',- 'echo',- 'ok',- ],- 'interval' => "{$this->database->health_check_interval}s",- 'timeout' => "{$this->database->health_check_timeout}s",- 'retries' => $this->database->health_check_retries,- 'start_period' => "{$this->database->health_check_start_period}s",- ],+ 'healthcheck' => $this->database->healthCheckConfiguration([+ 'CMD',+ 'echo',+ 'ok',+ ]),'mem_limit' => $this->database->limits_memory,'memswap_limit' => $this->database->limits_memory_swap,'mem_swappiness' => $this->database->limits_memory_swappiness,diff --git a/app/Actions/Database/StartMysql.php b/app/Actions/Database/StartMysql.phpindex f9d75e0c82..0445bddcd5 100644--- a/app/Actions/Database/StartMysql.php+++ b/app/Actions/Database/StartMysql.php@@ -103,13 +103,9 @@ class StartMysql$this->database->destination->network,],'labels' => defaultDatabaseLabels($this->database)->toArray(),- 'healthcheck' => [- 'test' => ['CMD', 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', "-p{$this->database->mysql_root_password}"],- 'interval' => "{$this->database->health_check_interval}s",- 'timeout' => "{$this->database->health_check_timeout}s",- 'retries' => $this->database->health_check_retries,- 'start_period' => "{$this->database->health_check_start_period}s",- ],+ 'healthcheck' => $this->database->healthCheckConfiguration([+ 'CMD', 'mysqladmin', 'ping', '-h', 'localhost', '-u', 'root', "-p{$this->database->mysql_root_password}",+ ]),'mem_limit' => $this->database->limits_memory,'memswap_limit' => $this->database->limits_memory_swap,'mem_swappiness' => $this->database->limits_memory_swappiness,diff --git a/app/Actions/Database/StartPostgresql.php b/app/Actions/Database/StartPostgresql.phpindex 520cbdec41..ae7ae98608 100644--- a/app/Actions/Database/StartPostgresql.php+++ b/app/Actions/Database/StartPostgresql.php@@ -110,13 +110,9 @@ class StartPostgresql$this->database->destination->network,],'labels' => defaultDatabaseLabels($this->database)->toArray(),- 'healthcheck' => [- 'test' => ['CMD', 'psql', '-U', (string) $this->database->postgres_user, '-d', (string) $this->database->postgres_db, '-c', 'SELECT 1'],- 'interval' => "{$this->database->health_check_interval}s",- 'timeout' => "{$this->database->health_check_timeout}s",- 'retries' => $this->database->health_check_retries,- 'start_period' => "{$this->database->health_check_start_period}s",- ],+ 'healthcheck' => $this->database->healthCheckConfiguration([+ 'CMD', 'psql', '-U', (string) $this->database->postgres_user, '-d', (string) $this->database->postgres_db, '-c', 'SELECT 1',+ ]),'mem_limit' => $this->database->limits_memory,'memswap_limit' => $this->database->limits_memory_swap,'mem_swappiness' => $this->database->limits_memory_swappiness,diff --git a/app/Actions/Database/StartRedis.php b/app/Actions/Database/StartRedis.phpindex e4bfd98e1a..64b434821b 100644--- a/app/Actions/Database/StartRedis.php+++ b/app/Actions/Database/StartRedis.php@@ -105,17 +105,11 @@ class StartRedis$this->database->destination->network,],'labels' => defaultDatabaseLabels($this->database)->toArray(),- 'healthcheck' => [- 'test' => [- 'CMD-SHELL',- 'redis-cli',- 'ping',- ],- 'interval' => "{$this->database->health_check_interval}s",- 'timeout' => "{$this->database->health_check_timeout}s",- 'retries' => $this->database->health_check_retries,- 'start_period' => "{$this->database->health_check_start_period}s",- ],+ 'healthcheck' => $this->database->healthCheckConfiguration([+ 'CMD-SHELL',+ 'redis-cli',+ 'ping',+ ]),'mem_limit' => $this->database->limits_memory,'memswap_limit' => $this->database->limits_memory_swap,'mem_swappiness' => $this->database->limits_memory_swappiness,diff --git a/app/Http/Controllers/Api/DatabasesController.php b/app/Http/Controllers/Api/DatabasesController.phpindex e2d2aad928..bceef4d39d 100644--- a/app/Http/Controllers/Api/DatabasesController.php+++ b/app/Http/Controllers/Api/DatabasesController.php@@ -299,11 +299,11 @@ class DatabasesController extends Controller'mysql_user' => ['type' => 'string', 'description' => 'MySQL user'],'mysql_database' => ['type' => 'string', 'description' => 'MySQL database'],'mysql_conf' => ['type' => 'string', 'description' => 'MySQL conf'],- 'health_check_enabled' => ['type' => 'boolean', 'description' => 'Enable the database healthcheck probe.'],- 'health_check_interval' => ['type' => 'integer', 'description' => 'Healthcheck interval in seconds.'],- 'health_check_timeout' => ['type' => 'integer', 'description' => 'Healthcheck timeout in seconds.'],- 'health_check_retries' => ['type' => 'integer', 'description' => 'Healthcheck retries count.'],- 'health_check_start_period' => ['type' => 'integer', 'description' => 'Healthcheck start period in seconds.'],+ 'health_check_enabled' => ['type' => 'boolean', 'description' => 'Enable the database healthcheck probe.', 'default' => true],+ 'health_check_interval' => ['type' => 'integer', 'description' => 'Healthcheck interval in seconds.', 'minimum' => 1, 'default' => 15],+ 'health_check_timeout' => ['type' => 'integer', 'description' => 'Healthcheck timeout in seconds.', 'minimum' => 1, 'default' => 5],+ 'health_check_retries' => ['type' => 'integer', 'description' => 'Healthcheck retries count.', 'minimum' => 1, 'default' => 5],+ 'health_check_start_period' => ['type' => 'integer', 'description' => 'Healthcheck start period in seconds.', 'minimum' => 0, 'default' => 5],],),)diff --git a/app/Livewire/Project/Database/Health.php b/app/Livewire/Project/Database/Health.phpindex 33540d74e6..535e73689b 100644--- a/app/Livewire/Project/Database/Health.php+++ b/app/Livewire/Project/Database/Health.php@@ -2,6 +2,7 @@namespace App\Livewire\Project\Database;+use Illuminate\Contracts\View\View;use Illuminate\Foundation\Auth\Access\AuthorizesRequests;use Livewire\Attributes\Validate;use Livewire\Component;@@ -27,7 +28,7 @@ class Health extends Component#[Validate(['integer', 'min:0'])]public int $healthCheckStartPeriod = 5;- public function mount()+ public function mount(): void{$this->authorize('view', $this->database);$this->syncData();@@ -52,29 +53,64 @@ class Health extends Component}}- public function instantSave()+ public function instantSave(): void{$this->submit();}- public function submit()+ public function submit(): void{+ $updateSuccessful = false;+try {$this->authorize('update', $this->database);$this->syncData(true);+ $updateSuccessful = true;$this->dispatch('success', 'Health check updated. Restart the database to apply the changes.');} catch (\Throwable $e) {- return handleError($e, $this);- } finally {- if (is_null($this->database->config_hash)) {- $this->database->isConfigurationChanged(true);- } else {- $this->dispatch('configurationChanged');- }+ handleError($e, $this);+ }++ if (! $updateSuccessful) {+ return;+ }++ $this->markConfigurationChanged();+ }++ public function toggleHealthcheck(): void+ {+ $updateSuccessful = false;++ try {+ $this->authorize('update', $this->database);+ $this->healthCheckEnabled = ! $this->healthCheckEnabled;+ $this->syncData(true);+ $updateSuccessful = true;+ $this->dispatch('success', 'Health check '.($this->healthCheckEnabled ? 'enabled' : 'disabled').'. Restart the database to apply the changes.');+ } catch (\Throwable $e) {+ handleError($e, $this);+ }++ if (! $updateSuccessful) {+ return;}++ $this->markConfigurationChanged();+ }++ private function markConfigurationChanged(): void+ {+ if (is_null($this->database->config_hash)) {+ $this->database->isConfigurationChanged(true);++ return;+ }++ $this->dispatch('configurationChanged');}- public function render()+ public function render(): View{return view('livewire.project.database.health');}diff --git a/app/Models/StandaloneClickhouse.php b/app/Models/StandaloneClickhouse.phpindex 1e68046f9e..b104be642d 100644--- a/app/Models/StandaloneClickhouse.php+++ b/app/Models/StandaloneClickhouse.php@@ -122,7 +122,7 @@ class StandaloneClickhouse extends BaseModelpublic function isConfigurationChanged(bool $save = false){$newConfigHash = $this->image.$this->ports_mappings;- $newConfigHash .= $this->health_check_enabled.$this->health_check_interval.$this->health_check_timeout.$this->health_check_retries.$this->health_check_start_period;+ $newConfigHash .= $this->healthCheckConfigurationHash();$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());$newConfigHash = md5($newConfigHash);$oldConfigHash = data_get($this, 'config_hash');diff --git a/app/Models/StandaloneDragonfly.php b/app/Models/StandaloneDragonfly.phpindex 5f76be8849..2232ec7725 100644--- a/app/Models/StandaloneDragonfly.php+++ b/app/Models/StandaloneDragonfly.php@@ -121,7 +121,7 @@ class StandaloneDragonfly extends BaseModelpublic function isConfigurationChanged(bool $save = false){$newConfigHash = $this->image.$this->ports_mappings;- $newConfigHash .= $this->health_check_enabled.$this->health_check_interval.$this->health_check_timeout.$this->health_check_retries.$this->health_check_start_period;+ $newConfigHash .= $this->healthCheckConfigurationHash();$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());$newConfigHash = md5($newConfigHash);$oldConfigHash = data_get($this, 'config_hash');diff --git a/app/Models/StandaloneKeydb.php b/app/Models/StandaloneKeydb.phpindex 6d3b5a82b9..b9f9f765b4 100644--- a/app/Models/StandaloneKeydb.php+++ b/app/Models/StandaloneKeydb.php@@ -122,7 +122,7 @@ class StandaloneKeydb extends BaseModelpublic function isConfigurationChanged(bool $save = false){$newConfigHash = $this->image.$this->ports_mappings.$this->keydb_conf;- $newConfigHash .= $this->health_check_enabled.$this->health_check_interval.$this->health_check_timeout.$this->health_check_retries.$this->health_check_start_period;+ $newConfigHash .= $this->healthCheckConfigurationHash();$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());$newConfigHash = md5($newConfigHash);$oldConfigHash = data_get($this, 'config_hash');diff --git a/app/Models/StandaloneMariadb.php b/app/Models/StandaloneMariadb.phpindex 1058d8721f..cd94b6c9bf 100644--- a/app/Models/StandaloneMariadb.php+++ b/app/Models/StandaloneMariadb.php@@ -125,7 +125,7 @@ class StandaloneMariadb extends BaseModelpublic function isConfigurationChanged(bool $save = false){$newConfigHash = $this->image.$this->ports_mappings.$this->mariadb_conf;- $newConfigHash .= $this->health_check_enabled.$this->health_check_interval.$this->health_check_timeout.$this->health_check_retries.$this->health_check_start_period;+ $newConfigHash .= $this->healthCheckConfigurationHash();$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());$newConfigHash = md5($newConfigHash);$oldConfigHash = data_get($this, 'config_hash');diff --git a/app/Models/StandaloneMongodb.php b/app/Models/StandaloneMongodb.phpindex 4657f1d5e3..7d2ffbd74f 100644--- a/app/Models/StandaloneMongodb.php+++ b/app/Models/StandaloneMongodb.php@@ -131,7 +131,7 @@ class StandaloneMongodb extends BaseModelpublic function isConfigurationChanged(bool $save = false){$newConfigHash = $this->image.$this->ports_mappings.$this->mongo_conf;- $newConfigHash .= $this->health_check_enabled.$this->health_check_interval.$this->health_check_timeout.$this->health_check_retries.$this->health_check_start_period;+ $newConfigHash .= $this->healthCheckConfigurationHash();$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());$newConfigHash = md5($newConfigHash);$oldConfigHash = data_get($this, 'config_hash');diff --git a/app/Models/StandaloneMysql.php b/app/Models/StandaloneMysql.phpindex f3d0ad55f6..f752312d34 100644--- a/app/Models/StandaloneMysql.php+++ b/app/Models/StandaloneMysql.php@@ -127,7 +127,7 @@ class StandaloneMysql extends BaseModelpublic function isConfigurationChanged(bool $save = false){$newConfigHash = $this->image.$this->ports_mappings.$this->mysql_conf;- $newConfigHash .= $this->health_check_enabled.$this->health_check_interval.$this->health_check_timeout.$this->health_check_retries.$this->health_check_start_period;+ $newConfigHash .= $this->healthCheckConfigurationHash();$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());$newConfigHash = md5($newConfigHash);$oldConfigHash = data_get($this, 'config_hash');diff --git a/app/Models/StandalonePostgresql.php b/app/Models/StandalonePostgresql.phpindex 39482892d0..04d2291b39 100644--- a/app/Models/StandalonePostgresql.php+++ b/app/Models/StandalonePostgresql.php@@ -169,7 +169,7 @@ class StandalonePostgresql extends BaseModelpublic function isConfigurationChanged(bool $save = false){$newConfigHash = $this->image.$this->ports_mappings.$this->postgres_initdb_args.$this->postgres_host_auth_method;- $newConfigHash .= $this->health_check_enabled.$this->health_check_interval.$this->health_check_timeout.$this->health_check_retries.$this->health_check_start_period;+ $newConfigHash .= $this->healthCheckConfigurationHash();$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());$newConfigHash = md5($newConfigHash);$oldConfigHash = data_get($this, 'config_hash');diff --git a/app/Models/StandaloneRedis.php b/app/Models/StandaloneRedis.phpindex 3d1d11138b..efb0254fbc 100644--- a/app/Models/StandaloneRedis.php+++ b/app/Models/StandaloneRedis.php@@ -126,7 +126,7 @@ class StandaloneRedis extends BaseModelpublic function isConfigurationChanged(bool $save = false){$newConfigHash = $this->image.$this->ports_mappings.$this->redis_conf;- $newConfigHash .= $this->health_check_enabled.$this->health_check_interval.$this->health_check_timeout.$this->health_check_retries.$this->health_check_start_period;+ $newConfigHash .= $this->healthCheckConfigurationHash();$newConfigHash .= json_encode($this->environment_variables()->get('value')->sort());$newConfigHash = md5($newConfigHash);$oldConfigHash = data_get($this, 'config_hash');diff --git a/app/Traits/HasDatabaseHealthCheck.php b/app/Traits/HasDatabaseHealthCheck.phpindex 2602ecb230..62ca345ed8 100644--- a/app/Traits/HasDatabaseHealthCheck.php+++ b/app/Traits/HasDatabaseHealthCheck.php@@ -31,4 +31,15 @@ trait HasDatabaseHealthCheck'start_period' => ($this->health_check_start_period ?? 5).'s',];}++ protected function healthCheckConfigurationHash(): string+ {+ return implode('|', [+ (int) ($this->health_check_enabled ?? true),+ $this->health_check_interval ?? 15,+ $this->health_check_timeout ?? 5,+ $this->health_check_retries ?? 5,+ $this->health_check_start_period ?? 5,+ ]);+ }}diff --git a/openapi.json b/openapi.jsonindex d3d25bacc8..f3bda9ab83 100644--- a/openapi.json+++ b/openapi.json@@ -4608,23 +4608,32 @@},"health_check_enabled": {"type": "boolean",- "description": "Enable the database healthcheck probe."+ "description": "Enable the database healthcheck probe.",+ "default": true},"health_check_interval": {"type": "integer",- "description": "Healthcheck interval in seconds."+ "description": "Healthcheck interval in seconds.",+ "minimum": 1,+ "default": 15},"health_check_timeout": {"type": "integer",- "description": "Healthcheck timeout in seconds."+ "description": "Healthcheck timeout in seconds.",+ "minimum": 1,+ "default": 5},"health_check_retries": {"type": "integer",- "description": "Healthcheck retries count."+ "description": "Healthcheck retries count.",+ "minimum": 1,+ "default": 5},"health_check_start_period": {"type": "integer",- "description": "Healthcheck start period in seconds."+ "description": "Healthcheck start period in seconds.",+ "minimum": 0,+ "default": 5}},"type": "object"diff --git a/openapi.yaml b/openapi.yamlindex 469a0c38d8..fae8d7110b 100644--- a/openapi.yaml+++ b/openapi.yaml@@ -2953,18 +2953,27 @@ paths:health_check_enabled:type: booleandescription: 'Enable the database healthcheck probe.'+ default: truehealth_check_interval:type: integerdescription: 'Healthcheck interval in seconds.'+ minimum: 1+ default: 15health_check_timeout:type: integerdescription: 'Healthcheck timeout in seconds.'+ minimum: 1+ default: 5health_check_retries:type: integerdescription: 'Healthcheck retries count.'+ minimum: 1+ default: 5health_check_start_period:type: integerdescription: 'Healthcheck start period in seconds.'+ minimum: 0+ default: 5type: objectresponses:'200':diff --git a/resources/views/livewire/project/database/configuration.blade.php b/resources/views/livewire/project/database/configuration.blade.phpindex d6aac7f30c..6e2ac208b3 100644--- a/resources/views/livewire/project/database/configuration.blade.php+++ b/resources/views/livewire/project/database/configuration.blade.php@@ -15,14 +15,14 @@href="{{ route('project.database.servers', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid]) }}"><span class="menu-item-label">Servers</span></a><a class='sub-menu-item' {{ wireNavigate() }} wire:current.exact="menu-item-active"href="{{ route('project.database.persistent-storage', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid]) }}"><span class="menu-item-label">Persistent Storage</span></a>- <a class='sub-menu-item' {{ wireNavigate() }} wire:current.exact="menu-item-active"- href="{{ route('project.database.healthcheck', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid]) }}"><span class="menu-item-label">Healthcheck</span></a>@can('update', $database)<a class='sub-menu-item' wire:current.exact="menu-item-active"href="{{ route('project.database.import-backup', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid]) }}"><span class="menu-item-label">Import Backup</span></a>@endcan<a class='sub-menu-item' {{ wireNavigate() }} wire:current.exact="menu-item-active"href="{{ route('project.database.webhooks', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid]) }}"><span class="menu-item-label">Webhooks</span></a>+ <a class='sub-menu-item' {{ wireNavigate() }} wire:current.exact="menu-item-active"+ href="{{ route('project.database.healthcheck', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid]) }}"><span class="menu-item-label">Healthcheck</span></a><a class="sub-menu-item" {{ wireNavigate() }} wire:current.exact="menu-item-active"href="{{ route('project.database.resource-limits', ['project_uuid' => $project->uuid, 'environment_uuid' => $environment->uuid, 'database_uuid' => $database->uuid]) }}"><span class="menu-item-label">Resource Limits</span></a><a class="sub-menu-item" {{ wireNavigate() }} wire:current.exact="menu-item-active"diff --git a/resources/views/livewire/project/database/health.blade.php b/resources/views/livewire/project/database/health.blade.phpindex d869defc17..7255002095 100644--- a/resources/views/livewire/project/database/health.blade.php+++ b/resources/views/livewire/project/database/health.blade.php@@ -2,25 +2,34 @@<div class="flex items-center gap-2"><h2>Healthcheck</h2><x-forms.button canGate="update" :canResource="$database" type="submit">Save</x-forms.button>+ @if (!$healthCheckEnabled)+ <x-modal-confirmation title="Confirm Healthcheck Enable?" buttonTitle="Enable Healthcheck"+ submitAction="toggleHealthcheck" :actions="['Enable healthcheck for this database.']"+ warningMessage="If the health check fails, this database will be marked unhealthy. Please review the <a href='https://coolify.io/docs/knowledge-base/health-checks' target='_blank' class='underline text-white'>Health Checks</a> guide before proceeding!"+ step2ButtonText="Enable Healthcheck" :confirmWithText="false" :confirmWithPassword="false"+ isHighlightedButton>+ </x-modal-confirmation>+ @else+ <x-forms.button canGate="update" :canResource="$database" wire:click="toggleHealthcheck">Disable Healthcheck</x-forms.button>+ @endif</div>- <div class="mt-1 pb-4">Configure how Docker checks this database's health. A higher interval lowers- <code>dockerd</code>/<code>containerd</code> CPU and load on servers running many databases. Restart the- database to apply changes.</div>+ <div class="mt-1 pb-4">Define how your resource's health should be checked.</div><div class="flex flex-col gap-4">- <x-forms.checkbox canGate="update" :canResource="$database" instantSave id="healthCheckEnabled"- label="Enabled"- helper="When disabled, Docker runs no healthcheck probe for this database and Coolify can no longer report a healthy/unhealthy state." />- @if ($healthCheckEnabled)- <div class="flex gap-2">- <x-forms.input canGate="update" :canResource="$database" min="1" type="number" id="healthCheckInterval"- placeholder="15" label="Interval (s)" required />- <x-forms.input canGate="update" :canResource="$database" min="1" type="number" id="healthCheckTimeout"- placeholder="5" label="Timeout (s)" required />- <x-forms.input canGate="update" :canResource="$database" min="1" type="number" id="healthCheckRetries"- placeholder="5" label="Retries" required />- <x-forms.input canGate="update" :canResource="$database" min="0" type="number"- id="healthCheckStartPeriod" placeholder="5" label="Start Period (s)" required />- </div>+ @if (!$healthCheckEnabled)+ <x-callout type="warning" title="Healthcheck disabled">+ <p>Docker runs no healthcheck probe for this database and Coolify can no longer report a healthy/unhealthy state.</p>+ </x-callout>@endif++ <div class="flex gap-2">+ <x-forms.input canGate="update" :canResource="$database" min="1" type="number" id="healthCheckInterval"+ placeholder="15" label="Interval (s)" required />+ <x-forms.input canGate="update" :canResource="$database" min="1" type="number" id="healthCheckTimeout"+ placeholder="5" label="Timeout (s)" required />+ <x-forms.input canGate="update" :canResource="$database" min="1" type="number" id="healthCheckRetries"+ placeholder="5" label="Retries" required />+ <x-forms.input canGate="update" :canResource="$database" min="0" type="number"+ id="healthCheckStartPeriod" placeholder="5" label="Start Period (s)" required />+ </div></div></form>diff --git a/resources/views/livewire/project/shared/health-checks.blade.php b/resources/views/livewire/project/shared/health-checks.blade.phpindex 8662b0b50b..ac2063c2ee 100644--- a/resources/views/livewire/project/shared/health-checks.blade.php+++ b/resources/views/livewire/project/shared/health-checks.blade.php@@ -1,6 +1,6 @@<form wire:submit='submit' class="flex flex-col"><div class="flex items-center gap-2">- <h2>Healthchecks</h2>+ <h2>Healthcheck</h2><x-forms.button canGate="update" :canResource="$resource" type="submit">Save</x-forms.button>@if (!$healthCheckEnabled)<x-modal-confirmation title="Confirm Healthcheck Enable?" buttonTitle="Enable Healthcheck"diff --git a/tests/Feature/DatabaseHealthCheckTest.php b/tests/Feature/DatabaseHealthCheckTest.phpindex 8bc1e4e923..9ccc3c53fb 100644--- a/tests/Feature/DatabaseHealthCheckTest.php+++ b/tests/Feature/DatabaseHealthCheckTest.php@@ -1,6 +1,8 @@<?php+use App\Livewire\Project\Database\Health;use App\Models\StandalonePostgresql;+use Illuminate\Auth\Access\AuthorizationException;it('defaults to an enabled healthcheck when nothing is configured', function () {$database = new StandalonePostgresql;@@ -43,3 +45,131 @@ it('reports the healthcheck as disabled when the flag is false', function () {expect($database->isHealthcheckEnabled())->toBeFalse();});++it('uses distinct hash fragments for ambiguous healthcheck values', function () {+ $enabledDatabase = new StandalonePostgresql([+ 'health_check_enabled' => true,+ 'health_check_interval' => 5,+ 'health_check_timeout' => 5,+ 'health_check_retries' => 5,+ 'health_check_start_period' => 5,+ ]);++ $disabledDatabase = new StandalonePostgresql([+ 'health_check_enabled' => false,+ 'health_check_interval' => 15,+ 'health_check_timeout' => 5,+ 'health_check_retries' => 5,+ 'health_check_start_period' => 5,+ ]);++ $getHashFragment = function () {+ return $this->healthCheckConfigurationHash();+ };++ expect($getHashFragment->call($enabledDatabase))+ ->toBe('1|5|5|5|5')+ ->not->toBe($getHashFragment->call($disabledDatabase))+ ->and($getHashFragment->call($disabledDatabase))->toBe('0|15|5|5|5');+});++it('does not mark configuration changed when health update authorization fails', function () {+ $database = new class+ {+ public ?string $config_hash = null;++ public int $configurationChangedChecks = 0;++ public function isConfigurationChanged(bool $save = false): bool+ {+ $this->configurationChangedChecks++;++ return true;+ }+ };++ $component = new class extends Health+ {+ public array $dispatchedEvents = [];++ public function authorize($ability, $arguments = [])+ {+ throw new AuthorizationException('This action is unauthorized.');+ }++ public function dispatch($event, ...$params)+ {+ $this->dispatchedEvents[] = $event;++ return null;+ }+ };++ $component->database = $database;+ $component->submit();++ expect($database->configurationChangedChecks)->toBe(0)+ ->and($component->dispatchedEvents)->toBe(['error']);+});++it('toggles database healthcheck and marks configuration changed', function () {+ $database = new class+ {+ public ?string $config_hash = 'existing';++ public bool $health_check_enabled = false;++ public int $health_check_interval = 15;++ public int $health_check_timeout = 5;++ public int $health_check_retries = 5;++ public int $health_check_start_period = 5;++ public int $saveCalls = 0;++ public function save(): void+ {+ $this->saveCalls++;+ }+ };++ $component = new class extends Health+ {+ public array $dispatchedEvents = [];++ public function authorize($ability, $arguments = [])+ {+ return true;+ }++ public function dispatch($event, ...$params)+ {+ $this->dispatchedEvents[] = $event;++ return null;+ }++ public function syncData(bool $toModel = false): void+ {+ if ($toModel) {+ $this->database->health_check_enabled = $this->healthCheckEnabled;+ $this->database->save();+ }+ }+ };++ $component->database = $database;+ $component->healthCheckEnabled = false;+ $component->healthCheckInterval = 15;+ $component->healthCheckTimeout = 5;+ $component->healthCheckRetries = 5;+ $component->healthCheckStartPeriod = 5;++ $component->toggleHealthcheck();++ expect($database->health_check_enabled)->toBeTrue()+ ->and($database->saveCalls)->toBe(1)+ ->and($component->dispatchedEvents)->toBe(['success', 'configurationChanged']);+});