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
sentinel updates
Andras Bacsaibea492165f18
diff --git a/app/Actions/Server/StartSentinel.php b/app/Actions/Server/StartSentinel.phpindex 4b45d0738e..a52fb41258 100644--- a/app/Actions/Server/StartSentinel.php+++ b/app/Actions/Server/StartSentinel.php@@ -10,32 +10,48 @@ class StartSentinel{use AsAction;- public function handle(Server $server, $version = 'latest', bool $restart = false)+ public function handle(Server $server, $version = 'next', bool $restart = false){if ($restart) {StopSentinel::run($server);}- $metrics_history = $server->settings->metrics_history_days;- $refresh_rate = $server->settings->metrics_refresh_rate_seconds;+ $metrics_history = $server->settings->sentinel_metrics_history_days;+ $refresh_rate = $server->settings->sentinel_metrics_refresh_rate_seconds;$token = $server->settings->sentinel_token;- $fqdn = InstanceSettings::get()->fqdn;- if (str($fqdn)->startsWith('http')) {- throw new \Exception('You should use https to run Sentinel.');+ $endpoint = InstanceSettings::get()->fqdn;+ if (isDev()) {+ $endpoint = 'http://host.docker.internal:8000';+ } else {+ if (str($endpoint)->startsWith('http')) {+ throw new \Exception('You should use https to run Sentinel.');+ }+ }+ if (! $endpoint) {+ throw new \Exception('You should set FQDN in Instance Settings.');}$environments = ['TOKEN' => $token,- 'ENDPOINT' => InstanceSettings::get()->fqdn,+ 'ENDPOINT' => $endpoint,'COLLECTOR_ENABLED' => 'true','COLLECTOR_REFRESH_RATE_SECONDS' => $refresh_rate,- 'COLLECTOR_RETENTION_PERIOD_DAYS' => $metrics_history+ 'COLLECTOR_RETENTION_PERIOD_DAYS' => $metrics_history,];- $docker_environments = "-e \"" . implode("\" -e \"", array_map(fn($key, $value) => "$key=$value", array_keys($environments), $environments)) . "\"";- ray($docker_environments);- return true;- // instant_remote_process([- // "docker run --rm --pull always -d $docker_environments --name coolify-sentinel -v /var/run/docker.sock:/var/run/docker.sock -v /data/coolify/sentinel:/app/sentinel --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:$version",- // 'chown -R 9999:root /data/coolify/sentinel',- // 'chmod -R 700 /data/coolify/sentinel',- // ], $server, true);+ if (isDev()) {+ data_set($environments, 'GIN_MODE', 'debug');+ }+ $mount_dir = '/data/coolify/sentinel';+ if (isDev()) {+ $mount_dir = '/var/lib/docker/volumes/coolify_dev_coolify_data/_data/sentinel';+ }+ $docker_environments = '-e "'.implode('" -e "', array_map(fn ($key, $value) => "$key=$value", array_keys($environments), $environments)).'"';+ $docker_command = "docker run --pull always --rm -d $docker_environments --name coolify-sentinel -v /var/run/docker.sock:/var/run/docker.sock -v $mount_dir:/app/db --pid host --health-cmd \"curl --fail http://127.0.0.1:8888/api/health || exit 1\" --health-interval 10s --health-retries 3 --add-host=host.docker.internal:host-gateway ghcr.io/coollabsio/sentinel:$version";++ return instant_remote_process([+ 'docker rm -f coolify-sentinel || true',+ "mkdir -p $mount_dir",+ $docker_command,+ "chown -R 9999:root $mount_dir",+ "chmod -R 700 $mount_dir",+ ], $server, true);}}diff --git a/app/Livewire/Server/Form.php b/app/Livewire/Server/Form.phpindex 6efff504b5..0bb7e47427 100644--- a/app/Livewire/Server/Form.php+++ b/app/Livewire/Server/Form.php@@ -101,7 +101,9 @@ class Form extends Component$this->server->settings->delete_unused_volumes = $server->settings->delete_unused_volumes;$this->server->settings->delete_unused_networks = $server->settings->delete_unused_networks;}- public function regenerateSentinelToken() {++ public function regenerateSentinelToken()+ {try {$this->server->generateSentinelToken();$this->server->settings->refresh();@@ -110,6 +112,7 @@ class Form extends Componentreturn handleError($e, $this);}}+public function updated($field){if ($field === 'server.settings.docker_cleanup_frequency') {@@ -186,25 +189,26 @@ class Form extends Componentpublic function getPushData(){try {- if (!isDev()) {+ if (! isDev()) {throw new \Exception('This feature is only available in dev mode.');}$response = Http::withHeaders([- 'Authorization' => 'Bearer ' . $this->server->settings->sentinel_token,+ 'Authorization' => 'Bearer '.$this->server->settings->sentinel_token,])->post('http://host.docker.internal:8888/api/push', ['data' => 'test',]);if ($response->successful()) {$this->dispatch('success', 'Push data sent.');+return;}$error = data_get($response->json(), 'error');throw new \Exception($error);-- } catch(\Throwable $e) {+ } catch (\Throwable $e) {return handleError($e, $this);}}+public function restartSentinel(){try {@@ -285,6 +289,7 @@ class Form extends Componentreturn handleError($e, $this);}}+public function manualCleanup(){try {@@ -302,4 +307,10 @@ class Form extends Component$this->server->refresh();$this->dispatch('success', 'Cloudflare Tunnels enabled.');}++ public function startSentinel()+ {+ StartSentinel::run($this->server);+ $this->dispatch('success', 'Sentinel started.');+ }}diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.phpindex ace297712f..47b686c1ea 100644--- a/resources/views/livewire/server/form.blade.php+++ b/resources/views/livewire/server/form.blade.php@@ -282,11 +282,10 @@{{-- @endif --}}</div>@if (isDev())- <x-forms.button wire:click="getPushData"> Push Test </x-forms.button>- {{-- <div class="w-64">+ <div class="w-64"><x-forms.checkbox instantSave id="server.settings.is_metrics_enabled" label="Enable Metrics" />- <x-forms.button>Start Sentinel</x-forms.button>- </div> --}}+ <x-forms.button wire:click="startSentinel">Start Sentinel</x-forms.button>+ </div><div class="flex flex-col gap-2"><div class="flex flex-wrap gap-2 sm:flex-nowrap items-end"><x-forms.input type="password" id="server.settings.sentinel_token" label="Metrics token"