Skip to content

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.

fix: sentinel config changes restarts sentinel

Andras Bacsai1f221d979195
diff --git a/app/Actions/Server/StartSentinel.php b/app/Actions/Server/StartSentinel.php
index f3ac7f5a3b..9eaafbd96a 100644
--- a/app/Actions/Server/StartSentinel.php
+++ b/app/Actions/Server/StartSentinel.php
@@ -9,8 +9,9 @@ class StartSentinel
{
use AsAction;
- public function handle(Server $server, $version = 'next', bool $restart = false)
+ public function handle(Server $server, bool $restart = false)
{
+ $version = get_latest_sentinel_version();
if ($server->isSwarm() || $server->isBuildServer()) {
return;
}
diff --git a/app/Jobs/PullSentinelImageJob.php b/app/Jobs/PullSentinelImageJob.php
index 32f84e6d50..054f81d998 100644
--- a/app/Jobs/PullSentinelImageJob.php
+++ b/app/Jobs/PullSentinelImageJob.php
@@ -33,7 +33,7 @@ class PullSentinelImageJob implements ShouldBeEncrypted, ShouldQueue
$local_version = '0.0.0';
}
if (version_compare($local_version, $version, '<')) {
- StartSentinel::run($this->server, $version, true);
+ StartSentinel::run($this->server, true);
return;
}
diff --git a/app/Livewire/Server/Form.php b/app/Livewire/Server/Form.php
index 289531fcb8..0e4263e530 100644
--- a/app/Livewire/Server/Form.php
+++ b/app/Livewire/Server/Form.php
@@ -97,7 +97,7 @@ class Form extends Component
try {
$this->server->settings->generateSentinelToken();
$this->server->settings->refresh();
- $this->restartSentinel(notification: false);
+ // $this->restartSentinel(notification: false);
$this->dispatch('success', 'Token regenerated & Sentinel restarted.');
} catch (\Throwable $e) {
return handleError($e, $this);
@@ -161,6 +161,7 @@ class Form extends Component
public function instantSave()
{
try {
+
$this->validate();
refresh_server_connection($this->server->privateKey);
$this->validateServer(false);
@@ -169,13 +170,11 @@ class Form extends Component
$this->server->save();
$this->dispatch('success', 'Server updated.');
$this->dispatch('refreshServerShow');
- $this->server->settings->save();
-
} catch (\Throwable $e) {
$this->server->settings->refresh();
return handleError($e, $this);
- }
+ } finally {}
}
public function restartSentinel($notification = true)
@@ -185,10 +184,9 @@ class Form extends Component
$this->validate([
'server.settings.sentinel_custom_url' => 'required|url',
]);
- $version = get_latest_sentinel_version();
- StartSentinel::run($this->server, $version, true);
+ $this->server->restartSentinel();
if ($notification) {
- $this->dispatch('success', 'Sentinel started.');
+ $this->dispatch('success', 'Sentinel restarted.');
}
} catch (\Throwable $e) {
return handleError($e, $this);
diff --git a/app/Models/Server.php b/app/Models/Server.php
index bc93676b64..1eb7496c9f 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\Jobs\PullSentinelImageJob;
use Illuminate\Database\Eloquent\Builder;
@@ -1265,4 +1266,13 @@ $schema://$host {
{
return str($this->ip)->contains(':');
}
+
+ public function restartSentinel()
+ {
+ try {
+ StartSentinel::dispatch($this,true);
+ } catch (\Throwable $e) {
+ loggy('Error restarting Sentinel: '.$e->getMessage());
+ }
+ }
}
diff --git a/app/Models/ServerSetting.php b/app/Models/ServerSetting.php
index d98647fced..fa767d8e79 100644
--- a/app/Models/ServerSetting.php
+++ b/app/Models/ServerSetting.php
@@ -70,6 +70,18 @@ class ServerSetting extends Model
loggy('Error creating server setting: '.$e->getMessage());
}
});
+ static::updated(function ($setting) {
+ if (
+ $setting->isDirty('sentinel_token') ||
+ $setting->isDirty('sentinel_custom_url') ||
+ $setting->isDirty('sentinel_metrics_refresh_rate_seconds') ||
+ $setting->isDirty('sentinel_metrics_history_days') ||
+ $setting->isDirty('sentinel_push_interval_seconds')
+ ) {
+ loggy('Restarting Sentinel');
+ $setting->server->restartSentinel();
+ }
+ });
}
public function generateSentinelToken(bool $save = true)