From 6acc0e60258662dd2d45fc2b48e31b3d0fed61db Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 8 Feb 2024 12:34:01 +0100 Subject: [PATCH] Add dynamic timeout for deployments --- app/Jobs/ApplicationDeploymentJob.php | 3 +- app/Livewire/Server/Form.php | 3 ++ config/queue.php | 2 +- ...04_add_dynamic_timeout_for_deployments.php | 28 +++++++++++++++++++ .../views/livewire/server/form.blade.php | 10 ++++--- 5 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 database/migrations/2024_02_08_112304_add_dynamic_timeout_for_deployments.php diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index fa828acbe..1b14e7e12 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -123,6 +123,7 @@ public function __construct(int $application_deployment_queue_id) $this->source = $source->getMorphClass()::where('id', $this->application->source->id)->first(); } $this->server = Server::find($this->application_deployment_queue->server_id); + $this->timeout = $this->server->settings->dynamic_timeout; $this->destination = $this->server->destinations()->where('id', $this->application_deployment_queue->destination_id)->first(); $this->server = $this->mainServer = $this->destination->server; $this->serverUser = $this->server->user; @@ -535,7 +536,7 @@ private function write_deployment_configurations() } private function push_to_docker_registry() { - $forceFail = false; + $forceFail = true; if (str($this->application->docker_registry_image_name)->isEmpty()) { ray('empty docker_registry_image_name'); return; diff --git a/app/Livewire/Server/Form.php b/app/Livewire/Server/Form.php index 936f8e724..bb9c7c3a1 100644 --- a/app/Livewire/Server/Form.php +++ b/app/Livewire/Server/Form.php @@ -28,6 +28,7 @@ class Form extends Component 'server.settings.is_swarm_worker' => 'required|boolean', 'server.settings.is_build_server' => 'required|boolean', 'server.settings.concurrent_builds' => 'required|integer|min:1', + 'server.settings.dynamic_timeout' => 'required|integer|min:1', 'wildcard_domain' => 'nullable|url', ]; protected $validationAttributes = [ @@ -42,6 +43,8 @@ class Form extends Component 'server.settings.is_swarm_worker' => 'Swarm Worker', 'server.settings.is_build_server' => 'Build Server', 'server.settings.concurrent_builds' => 'Concurrent Builds', + 'server.settings.dynamic_timeout' => 'Dynamic Timeout', + ]; public function mount() diff --git a/config/queue.php b/config/queue.php index 2ef618584..a46085a9f 100644 --- a/config/queue.php +++ b/config/queue.php @@ -65,7 +65,7 @@ 'driver' => 'redis', 'connection' => 'default', 'queue' => env('REDIS_QUEUE', 'default'), - 'retry_after' => 3600, + 'retry_after' => 86400, 'block_for' => null, 'after_commit' => true, ], diff --git a/database/migrations/2024_02_08_112304_add_dynamic_timeout_for_deployments.php b/database/migrations/2024_02_08_112304_add_dynamic_timeout_for_deployments.php new file mode 100644 index 000000000..f45bd7a2a --- /dev/null +++ b/database/migrations/2024_02_08_112304_add_dynamic_timeout_for_deployments.php @@ -0,0 +1,28 @@ +integer('dynamic_timeout')->default(3600); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('server_settings', function (Blueprint $table) { + $table->dropColumn('dynamic_timeout'); + }); + } +}; diff --git a/resources/views/livewire/server/form.blade.php b/resources/views/livewire/server/form.blade.php index 0a50321e8..8259a997d 100644 --- a/resources/views/livewire/server/form.blade.php +++ b/resources/views/livewire/server/form.blade.php @@ -42,7 +42,7 @@ class="w-full mt-8 mb-4 font-bold box-without-bg bg-coollabs hover:bg-coollabs-1 @if (!$server->settings->is_swarm_worker && !$server->settings->is_build_server) + helper='A wildcard domain allows you to receive a randomly generated domain for your new applications.

For instance, if you set "https://example.com" as your wildcard domain, your applications will receive domains like "https://randomId.example.com".' /> @endif @@ -61,7 +61,7 @@ class="w-full mt-8 mb-4 font-bold box-without-bg bg-coollabs hover:bg-coollabs-1 label="Use it as a build server?" /> @else @if ($server->isSwarm())
Swarm support is experimental.
@@ -93,9 +93,11 @@ class="w-full mt-8 mb-4 font-bold box-without-bg bg-coollabs hover:bg-coollabs-1

Settings

+ helper="The disk cleanup task will run when the disk usage exceeds this threshold." /> + helper="You can specify the number of simultaneous build processes/deployments that should run concurrently." /> +
@endif