fix: better server vlaidation

fix: remove unnecessary coolify.yaml from cloud hosted servers
This commit is contained in:
Andras Bacsai
2024-05-03 10:22:28 +02:00
parent 140ec1f90f
commit f4cb7cea21
3 changed files with 60 additions and 58 deletions

View File

@@ -38,11 +38,12 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted
public function handle()
{
if (!$this->server->isServerReady($this->tries)) {
throw new \RuntimeException('Server is not ready.');
return "Server is not ready yet.";
};
try {
if ($this->server->isFunctional()) {
$this->cleanup(notify: false);
$this->removeCoolifyYaml();
}
} catch (\Throwable $e) {
send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage());
@@ -50,6 +51,16 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted
return handleError($e);
}
}
private function removeCoolifyYaml()
{
// This will remote the coolify.yaml file from the server as it is not needed on cloud servers
if (isCloud()) {
$file = $this->server->proxyPath() . "/dynamic/coolify.yaml";
return instant_remote_process([
"rm -f $file",
], $this->server, false);
}
}
public function cleanup(bool $notify = false): void
{
$this->disk_usage = $this->server->getDiskUsage();