From 50e17ed932ebe52961a3cd806335b25f0248a642 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 11:21:17 +0100 Subject: [PATCH 01/12] fix: server ready --- app/Models/Server.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Models/Server.php b/app/Models/Server.php index 285ce01db..7cc0983c0 100644 --- a/app/Models/Server.php +++ b/app/Models/Server.php @@ -151,7 +151,12 @@ class Server extends BaseModel } public function isServerReady(int $tries = 3) { - $serverUptimeCheckNumber = $this->unreachable_count + 1; + if ($this->skipServer()) { + return false; + } + if ($this->unreachable_count < $tries) { + $serverUptimeCheckNumber = $this->unreachable_count + 1; + } $serverUptimeCheckNumberMax = $tries; ray('server: ' . $this->name); From 3a4f19f3685c4bfa2558de8136ba358b6f8abad9 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 11:22:10 +0100 Subject: [PATCH 02/12] version++ --- config/sentry.php | 2 +- config/version.php | 2 +- versions.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/sentry.php b/config/sentry.php index b24ec892f..e4fbdc97a 100644 --- a/config/sentry.php +++ b/config/sentry.php @@ -7,7 +7,7 @@ return [ // The release version of your application // Example with dynamic git hash: trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')) - 'release' => '4.0.0-beta.165', + 'release' => '4.0.0-beta.166', // When left empty or `null` the Laravel environment will be used 'environment' => config('app.env'), diff --git a/config/version.php b/config/version.php index a0b2aca88..313acc6cc 100644 --- a/config/version.php +++ b/config/version.php @@ -1,3 +1,3 @@ Date: Wed, 20 Dec 2023 11:37:04 +0100 Subject: [PATCH 03/12] hm --- app/Jobs/ContainerStatusJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 15dad0a06..dcb962a38 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -29,7 +29,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted } public function middleware(): array { - return [(new WithoutOverlapping($this->server->uuid))]; + return [(new WithoutOverlapping($this->server->uuid))->dontRelease()]; } public function uniqueId(): int From 2549244f976374f7db8422931fdb32e5d9f5b9e7 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 11:44:46 +0100 Subject: [PATCH 04/12] hm --- app/Livewire/Server/New/ByIp.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Livewire/Server/New/ByIp.php b/app/Livewire/Server/New/ByIp.php index 1849cdfbc..ba94063cd 100644 --- a/app/Livewire/Server/New/ByIp.php +++ b/app/Livewire/Server/New/ByIp.php @@ -93,7 +93,7 @@ class ByIp extends Component $server->settings->is_swarm_worker = $this->is_swarm_worker; $server->settings->save(); $server->addInitialNetwork(); - return $this->redirectRoute('server.show', $server->uuid, navigate: true); + return $this->redirectRoute('server.show', $server->uuid); } catch (\Throwable $e) { return handleError($e, $this); } From 94960d96a90056e29c16d3bc104fd0685ed47499 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 11:47:51 +0100 Subject: [PATCH 05/12] add max horizon processes --- config/horizon.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/horizon.php b/config/horizon.php index 14d20e1cf..060e67bad 100644 --- a/config/horizon.php +++ b/config/horizon.php @@ -216,7 +216,7 @@ return [ ], 'long-running' => [ 'autoScalingStrategy' => 'size', - 'maxProcesses' => env('HORIZON_MAX_PROCESSES', 2), + 'maxProcesses' => env('HORIZON_MAX_PROCESSES', 6), 'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1), 'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1), ], @@ -231,7 +231,7 @@ return [ ], 'long-running' => [ 'autoScalingStrategy' => 'size', - 'maxProcesses' => env('HORIZON_MAX_PROCESSES', 2), + 'maxProcesses' => env('HORIZON_MAX_PROCESSES', 6), 'balanceMaxShift' => env('HORIZON_BALANCE_MAX_SHIFT', 1), 'balanceCooldown' => env('HORIZON_BALANCE_COOLDOWN', 1), ], From 64b58b76613046e617323aacefe69afe1445c87d Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 11:59:06 +0100 Subject: [PATCH 06/12] hm --- app/Jobs/ContainerStatusJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index dcb962a38..15dad0a06 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -29,7 +29,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted } public function middleware(): array { - return [(new WithoutOverlapping($this->server->uuid))->dontRelease()]; + return [(new WithoutOverlapping($this->server->uuid))]; } public function uniqueId(): int From 27b6aad53a56e975872706e181e834daa3dcce93 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 11:59:53 +0100 Subject: [PATCH 07/12] fix --- app/Jobs/ContainerStatusJob.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index 15dad0a06..a8b2c1a9a 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -22,10 +22,10 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public $tries = 5; + public $tries = 4; public function backoff(): int { - return isDev() ? 1 : 5; + return isDev() ? 1 : 3; } public function middleware(): array { From cd842bc1b2a240721984db522bdb3f335a86cd79 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 12:13:34 +0100 Subject: [PATCH 08/12] Update number of tries in ContainerStatusJob --- app/Jobs/ContainerStatusJob.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index a8b2c1a9a..f42e1e7ea 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -22,7 +22,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public $tries = 4; + public $tries = 5; public function backoff(): int { return isDev() ? 1 : 3; From 5f2ad56529b118acfa9d4b417627e4c3734391c6 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 12:25:14 +0100 Subject: [PATCH 09/12] Update container and server status job --- app/Jobs/ContainerStatusJob.php | 2 +- app/Jobs/ServerStatusJob.php | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/Jobs/ContainerStatusJob.php b/app/Jobs/ContainerStatusJob.php index f42e1e7ea..a8b2c1a9a 100644 --- a/app/Jobs/ContainerStatusJob.php +++ b/app/Jobs/ContainerStatusJob.php @@ -22,7 +22,7 @@ class ContainerStatusJob implements ShouldQueue, ShouldBeEncrypted { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; - public $tries = 5; + public $tries = 4; public function backoff(): int { return isDev() ? 1 : 3; diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.php index 58f30b18d..20b564fe8 100644 --- a/app/Jobs/ServerStatusJob.php +++ b/app/Jobs/ServerStatusJob.php @@ -34,9 +34,10 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted { ray("checking server status for {$this->server->id}"); try { - if ($this->server->isFunctional()) { - $this->cleanup(notify: false); - } + if (!$this->server->isServerReady(4)) { + throw new \RuntimeException('Server is not reachable.'); + }; + $this->cleanup(notify: false); } catch (\Throwable $e) { send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage()); ray($e->getMessage()); From c41cfe2a2fe235dcbad0b910ae5f9040dc8e4b70 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 12:32:46 +0100 Subject: [PATCH 10/12] Fix server status check and cleanup logic --- app/Jobs/ServerStatusJob.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.php index 20b564fe8..c162d3bc3 100644 --- a/app/Jobs/ServerStatusJob.php +++ b/app/Jobs/ServerStatusJob.php @@ -33,11 +33,13 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted 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->isServerReady(4)) { - throw new \RuntimeException('Server is not reachable.'); - }; - $this->cleanup(notify: false); + if ($this->server->isFunctional()) { + $this->cleanup(notify: false); + } } catch (\Throwable $e) { send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage()); ray($e->getMessage()); From 66b41b3d4c916ace66c6b0d8fc64406b1867c0bb Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 12:33:21 +0100 Subject: [PATCH 11/12] Update ServerStatusJob middleware and uniqueId() method --- app/Jobs/ServerStatusJob.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.php index c162d3bc3..2cdf4d547 100644 --- a/app/Jobs/ServerStatusJob.php +++ b/app/Jobs/ServerStatusJob.php @@ -17,17 +17,22 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public ?int $disk_usage = null; + public $tries = 4; + public function backoff(): int + { + return isDev() ? 1 : 3; + } public function __construct(public Server $server) { } public function middleware(): array { - return [(new WithoutOverlapping($this->server->id))->dontRelease()]; + return [(new WithoutOverlapping($this->server->uuid))]; } public function uniqueId(): int { - return $this->server->id; + return $this->server->uuid; } public function handle(): void From c9a1437870a1eead595744ed8a3709e14f8b9124 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Wed, 20 Dec 2023 12:33:58 +0100 Subject: [PATCH 12/12] Fix handle method in ServerStatusJob --- app/Jobs/ServerStatusJob.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Jobs/ServerStatusJob.php b/app/Jobs/ServerStatusJob.php index 2cdf4d547..96fc8f75c 100644 --- a/app/Jobs/ServerStatusJob.php +++ b/app/Jobs/ServerStatusJob.php @@ -35,7 +35,7 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted return $this->server->uuid; } - public function handle(): void + public function handle() { ray("checking server status for {$this->server->id}"); if (!$this->server->isServerReady(4)) { @@ -48,7 +48,7 @@ class ServerStatusJob implements ShouldQueue, ShouldBeEncrypted } catch (\Throwable $e) { send_internal_notification('ServerStatusJob failed with: ' . $e->getMessage()); ray($e->getMessage()); - handleError($e); + return handleError($e); } } public function cleanup(bool $notify = false): void