server->uuid))]; } public function uniqueId(): int { return $this->server->uuid; } public function handle(): void { ray("checking server status for {$this->server->id}"); if (!$this->server->isServerReady(4)) { throw new \RuntimeException('Server is not reachable.'); }; try { if ($this->server->isFunctional()) { $this->cleanup(notify: false); } } catch (\Throwable $e) { send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage()); ray($e->getMessage()); handleError($e); } } public function cleanup(bool $notify = false): void { $this->disk_usage = $this->server->getDiskUsage(); if ($this->disk_usage >= $this->server->settings->cleanup_after_percentage) { if ($notify) { if ($this->server->high_disk_usage_notification_sent) { ray('high disk usage notification already sent'); return; } else { $this->server->high_disk_usage_notification_sent = true; $this->server->save(); $this->server->team?->notify(new HighDiskUsage($this->server, $this->disk_usage, $this->server->settings->cleanup_after_percentage)); } } else { DockerCleanupJob::dispatchSync($this->server); $this->cleanup(notify: true); } } else { $this->server->high_disk_usage_notification_sent = false; $this->server->save(); } } }