diff --git a/app/Jobs/ApplicationDeploymentJob.php b/app/Jobs/ApplicationDeploymentJob.php index 40ae43428..505b9727b 100644 --- a/app/Jobs/ApplicationDeploymentJob.php +++ b/app/Jobs/ApplicationDeploymentJob.php @@ -184,6 +184,9 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted public function handle(): void { + $this->application_deployment_queue->update([ + 'status' => ApplicationDeploymentStatus::IN_PROGRESS->value, + ]); if (!$this->server->isFunctional()) { $this->application_deployment_queue->addLogEntry("Server is not functional."); $this->fail("Server is not functional."); @@ -988,6 +991,7 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted } if (Str::of($this->saved_outputs->get('health_check'))->replace('"', '')->value() === 'unhealthy') { $this->newVersionIsHealthy = false; + $this->query_logs(); break; } $counter++; @@ -997,9 +1001,25 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted $sleeptime++; } } + if (Str::of($this->saved_outputs->get('health_check'))->replace('"', '')->value() === 'starting') { + $this->query_logs(); + } } } } + private function query_logs() + { + $this->application_deployment_queue->addLogEntry("----------------------------------------"); + $this->application_deployment_queue->addLogEntry("Container logs:"); + $this->execute_remote_command( + [ + "command" => "docker logs -n 100 {$this->container_name}", + "type" => "stderr", + "ignore_errors" => true, + ], + ); + $this->application_deployment_queue->addLogEntry("----------------------------------------"); + } private function deploy_pull_request() { if ($this->application->build_pack === 'dockercompose') { diff --git a/bootstrap/helpers/applications.php b/bootstrap/helpers/applications.php index a1995c645..f4dcc0891 100644 --- a/bootstrap/helpers/applications.php +++ b/bootstrap/helpers/applications.php @@ -43,16 +43,10 @@ function queue_application_deployment(Application $application, string $deployme ]); if ($no_questions_asked) { - $deployment->update([ - 'status' => ApplicationDeploymentStatus::IN_PROGRESS->value, - ]); dispatch(new ApplicationDeploymentJob( application_deployment_queue_id: $deployment->id, )); } else if (next_queuable($server_id, $application_id)) { - $deployment->update([ - 'status' => ApplicationDeploymentStatus::IN_PROGRESS->value, - ]); dispatch(new ApplicationDeploymentJob( application_deployment_queue_id: $deployment->id, ));