Files
coolify/app/Jobs/CheckForUpdatesJob.php
T
peaklabs-dev 0e30950793 feat(release): streamline versions.json on the CDN
- Every channel has a block of its own, every version after this one reads only these blocks
- Every stable sync also fills the coolify and traefik keys older instances read
- An instance keeps a copy of versions.json and reads upstream.json of the image until it has one
2026-11-02 00:07:20 +01:00

54 lines
1.6 KiB
PHP

<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeEncrypted;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Log;
class CheckForUpdatesJob implements ShouldBeEncrypted, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/** A manual check runs in the web request, so it does not wait for CDN retries. */
public int $cdnTries = 3;
public function __construct(int $cdnTries = 3)
{
$this->cdnTries = $cdnTries;
}
/**
* @return bool Whether the check finished and new_version_available is up to date
*/
public function handle(): bool
{
try {
if (isDev() || isCloud()) {
return false;
}
$versions = refresh_versions_file($this->cdnTries);
if ($versions === null) {
return false;
}
CheckTraefikVersionJob::dispatch();
$latestVersion = data_get($versions, 'coolify.version');
$newVersionAvailable = instanceSettings()->update_channel !== 'custom'
&& version_compare($latestVersion, config('constants.coolify.version'), '>');
instanceSettings()->update(['new_version_available' => $newVersionAvailable]);
return true;
} catch (\Throwable $e) {
Log::warning('Could not check for Coolify updates', ['error' => $e->getMessage()]);
return false;
}
}
}