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
feat: start Sentinel on servers.
Andras Bacsaic618e58a117b
diff --git a/app/Actions/Docker/GetContainersStatus.php b/app/Actions/Docker/GetContainersStatus.phpindex d606c75328..80f8c7d980 100644--- a/app/Actions/Docker/GetContainersStatus.php+++ b/app/Actions/Docker/GetContainersStatus.php@@ -55,10 +55,10 @@ class GetContainersStatus$sentinel_found = json_decode($sentinel_found, true);$status = data_get($sentinel_found, '0.State.Status', 'exited');if ($status === 'running') {- ray('Sentinel');+ ray('Checking with Sentinel');$this->sentinel();} else {- ray('Old way');+ ray('Checking the Old way');$this->old_way();}}diff --git a/app/Actions/Server/StartSentinel.php b/app/Actions/Server/StartSentinel.phpnew file mode 100644index 0000000000..b8b89a706c--- /dev/null+++ b/app/Actions/Server/StartSentinel.php@@ -0,0 +1,15 @@+<?php++namespace App\Actions\Server;++use Lorisleiva\Actions\Concerns\AsAction;+use App\Models\Server;++class StartSentinel+{+ use AsAction;+ public function handle(Server $server)+ {+ return instant_remote_process(['docker run --pull always -d --name coolify-sentinel --restart always -p 127.0.0.1:8888:8888 -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify/metrics:/var/www/html/storage/app/metrics --pid host --health-cmd "curl --fail http://127.0.0.1:8888/api/health || exit 1" --health-interval 10s --health-retries 3 ghcr.io/coollabsio/sentinel:latest'], $server, false);+ }+}diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.phpindex 6402b81cf0..0a9198d004 100644--- a/app/Jobs/ServerStatusJob.php+++ b/app/Jobs/ServerStatusJob.php@@ -44,6 +44,7 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncryptedif ($this->server->isFunctional()) {$this->cleanup(notify: false);$this->removeCoolifyYaml();+ $this->server->checkSentinel();}} catch (\Throwable $e) {send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage());diff --git a/app/Models/Server.php b/app/Models/Server.phpindex 19da8d7842..16659e2b8b 100644--- a/app/Models/Server.php+++ b/app/Models/Server.php@@ -3,6 +3,7 @@namespace App\Models;use App\Actions\Server\InstallDocker;+use App\Actions\Server\StartSentinel;use App\Enums\ProxyTypes;use App\Notifications\Server\Revived;use App\Notifications\Server\Unreachable;@@ -462,6 +463,20 @@ $schema://$host {Storage::disk('ssh-keys')->delete($sshKeyFileLocation);Storage::disk('ssh-mux')->delete($this->muxFilename());}+ public function checkSentinel() {+ ray("Checking sentinel on server: {$this->name}");+ if ($this->is_metrics_enabled) {+ $sentinel_found = instant_remote_process(["docker inspect coolify-sentinel"], $this, false);+ $sentinel_found = json_decode($sentinel_found, true);+ $status = data_get($sentinel_found, '0.State.Status', 'exited');+ if ($status !== 'running') {+ ray('Sentinel is not running, starting it...');+ StartSentinel::dispatch($this);+ } else {+ ray('Sentinel is running');+ }+ }+ }public function isServerReady(int $tries = 3){if ($this->skipServer()) {diff --git a/docker-compose.prod.yml b/docker-compose.prod.ymlindex 57dedea920..b934d8222e 100644--- a/docker-compose.prod.yml+++ b/docker-compose.prod.yml@@ -112,6 +112,9 @@ services:- "127.0.0.1:8888:8888"healthcheck:test: curl --fail http://127.0.0.1:8888/api/health || exit 1+ interval: 10s+ retries: 2+ timeout: 5spostgres:volumes:- coolify-db:/var/lib/postgresql/data