mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
- ServerCheckJob uses the stored reachability state instead of a second SSH probe. One failed probe no longer marks the server unreachable without UNREACHABLE_THRESHOLD or marks all its resources exited. - Do not dispatch ServerCheckJob for build servers and Swarm workers. - Check cloud provider state every 5 minutes instead of every minute. - ServerPatchCheckJob uses isFunctional() and drops the unused retries. - Delete the unused ServerCleanupMux job. - Disable SSH multiplexing per command. The global config change stayed in the queue worker, so later jobs (also deployments) ran without mux.
71 lines
2.1 KiB
PHP
71 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Actions\Server\CheckUpdates;
|
|
use App\Models\Server;
|
|
use App\Notifications\Server\ServerPatchCheck;
|
|
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\Middleware\WithoutOverlapping;
|
|
use Illuminate\Queue\SerializesModels;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
class ServerPatchCheckJob implements ShouldBeEncrypted, ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
public $timeout = 600;
|
|
|
|
public function middleware(): array
|
|
{
|
|
return [(new WithoutOverlapping('server-patch-check-'.$this->server->uuid))->expireAfter(600)->dontRelease()];
|
|
}
|
|
|
|
public function __construct(public Server $server)
|
|
{
|
|
$this->onQueue(maintenance_queue());
|
|
}
|
|
|
|
public function handle(): void
|
|
{
|
|
try {
|
|
if ($this->server->isFunctional() === false) {
|
|
return;
|
|
}
|
|
|
|
$team = data_get($this->server, 'team');
|
|
if (! $team) {
|
|
return;
|
|
}
|
|
|
|
// Check for updates
|
|
$patchData = CheckUpdates::run($this->server);
|
|
|
|
if (isset($patchData['error'])) {
|
|
$team->notify(new ServerPatchCheck($this->server, $patchData));
|
|
|
|
return; // Skip if there's an error checking for updates
|
|
}
|
|
|
|
$totalUpdates = $patchData['total_updates'] ?? 0;
|
|
|
|
// Only send notification if there are updates available
|
|
if ($totalUpdates > 0) {
|
|
$team->notify(new ServerPatchCheck($this->server, $patchData));
|
|
}
|
|
} catch (\Throwable $e) {
|
|
// Log error but don't fail the job
|
|
Log::error('ServerPatchCheckJob failed: '.$e->getMessage(), [
|
|
'server_id' => $this->server->id,
|
|
'server_name' => $this->server->name,
|
|
'error' => $e->getMessage(),
|
|
'trace' => $e->getTraceAsString(),
|
|
]);
|
|
}
|
|
}
|
|
}
|