Refactor PullSentinelImageJob.php to only start Sentinel if local version is outdated

This commit is contained in:
Andras Bacsai 2024-05-08 19:32:13 +02:00
parent 1a152a5597
commit 781bf52a8e

View File

@ -39,12 +39,11 @@ public function handle(): void
return; return;
} }
$local_version = instant_remote_process(['docker exec coolify-sentinel sh -c "curl http://127.0.0.1:8888/api/version"'], $this->server, '0.0.0'); $local_version = instant_remote_process(['docker exec coolify-sentinel sh -c "curl http://127.0.0.1:8888/api/version"'], $this->server, '0.0.0');
if ($version === $local_version) { if (version_compare($local_version, $version, '<')) {
ray('Sentinel image is up to date'); StartSentinel::run($this->server, $version, true);
return; return;
} }
ray('Pulling Sentinel image'); ray('Sentinel image is up to date');
StartSentinel::run($this->server, $version, true);
} catch (\Throwable $e) { } catch (\Throwable $e) {
send_internal_notification('PullSentinelImageJob failed with: ' . $e->getMessage()); send_internal_notification('PullSentinelImageJob failed with: ' . $e->getMessage());
ray($e->getMessage()); ray($e->getMessage());