mirror of
https://github.com/tiennm99/coolify.git
synced 2026-10-15 10:14:47 +00:00
fix(sentinel): prevent restart after Sentinel is disabled (#11298)
This commit is contained in:
1 parent
1c25b58dc8
commit
81ed9a3af2
2 files changed
+48
-3
No files matched your search
@@ -21,6 +21,10 @@ class CheckAndStartSentinelJob implements ShouldBeEncrypted, ShouldQueue
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
if (! $this->sentinelIsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$latestVersion = get_latest_sentinel_version();
|
||||
|
||||
// Check if sentinel is running
|
||||
@@ -28,7 +32,7 @@ class CheckAndStartSentinelJob implements ShouldBeEncrypted, ShouldQueue
|
||||
$sentinelFoundJson = json_decode($sentinelFound, true);
|
||||
$sentinelStatus = data_get($sentinelFoundJson, '0.State.Status', 'exited');
|
||||
if ($sentinelStatus !== 'running') {
|
||||
StartSentinel::run(server: $this->server, restart: true, latestVersion: $latestVersion);
|
||||
$this->startSentinel($latestVersion);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -38,15 +42,31 @@ class CheckAndStartSentinelJob implements ShouldBeEncrypted, ShouldQueue
|
||||
$runningVersion = '0.0.0';
|
||||
}
|
||||
if ($latestVersion === '0.0.0' && $runningVersion === '0.0.0') {
|
||||
StartSentinel::run(server: $this->server, restart: true, latestVersion: 'latest');
|
||||
$this->startSentinel('latest');
|
||||
|
||||
return;
|
||||
} else {
|
||||
if (version_compare($runningVersion, $latestVersion, '<')) {
|
||||
StartSentinel::run(server: $this->server, restart: true, latestVersion: $latestVersion);
|
||||
$this->startSentinel($latestVersion);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function sentinelIsEnabled(): bool
|
||||
{
|
||||
$this->server->unsetRelation('settings');
|
||||
|
||||
return $this->server->isSentinelEnabled();
|
||||
}
|
||||
|
||||
private function startSentinel(string $latestVersion): void
|
||||
{
|
||||
if (! $this->sentinelIsEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
StartSentinel::run(server: $this->server, restart: true, latestVersion: $latestVersion);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user