Fix server readiness check in ContainerStatusJob

and ServerStatusJob
This commit is contained in:
Andras Bacsai
2023-11-17 13:04:51 +01:00
parent 5ae08d009e
commit 2c4e69ad50
3 changed files with 7 additions and 3 deletions

View File

@@ -39,7 +39,9 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted
{ {
// ray("checking server status for {$this->server->id}"); // ray("checking server status for {$this->server->id}");
try { try {
$this->server->checkServerRediness(); if (!$this->server->checkServerRediness()) {
return;
}
$containers = instant_remote_process(["docker container ls -q"], $this->server); $containers = instant_remote_process(["docker container ls -q"], $this->server);
if (!$containers) { if (!$containers) {
return; return;

View File

@@ -34,7 +34,9 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted
{ {
ray("checking server status for {$this->server->id}"); ray("checking server status for {$this->server->id}");
try { try {
$this->server->checkServerRediness(); if (!$this->server->checkServerRediness()) {
return;
}
$this->cleanup(notify: false); $this->cleanup(notify: false);
} catch (\Throwable $e) { } catch (\Throwable $e) {
send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage()); send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage());

View File

@@ -131,7 +131,7 @@ class Server extends BaseModel
public function checkServerRediness() public function checkServerRediness()
{ {
if ($this->skipServer()) { if ($this->skipServer()) {
return; return false;
} }
$serverUptimeCheckNumber = $this->unreachable_count; $serverUptimeCheckNumber = $this->unreachable_count;
$serverUptimeCheckNumberMax = 5; $serverUptimeCheckNumberMax = 5;