onQueue('high'); } public function handle(): void { if (! $this->server->canBeValidated() || $this->server->is_validating || $this->server->isFunctional()) { return; } if ($this->isReady()) { ValidateAndInstallServerJob::dispatch($this->server); return; } if ($this->attempt >= self::MAX_ATTEMPTS) { $this->server->update([ 'validation_logs' => 'The server did not start or accept SSH connections within '.(self::MAX_ATTEMPTS * self::RETRY_DELAY_SECONDS / 60).' minutes after it was created. Validate it manually.', ]); return; } self::dispatch($this->server, $this->attempt + 1)->delay(now()->addSeconds(self::RETRY_DELAY_SECONDS)); } private function isReady(): bool { try { $status = $this->server->refreshCloudProviderState(); } catch (\Throwable) { return false; } if (! in_array($status, ['running', 'active'], true) || $this->server->hasPlaceholderIp()) { return false; } return $this->server->validateConnection()['uptime']; } }