From aba0b2f13c0b32327a27ba3cb733546e6ce3430b Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 14 Sep 2023 18:29:54 +0200 Subject: [PATCH] remove unnecessary jobs --- app/Jobs/ApplicationContainerStatusJob.php | 54 -------------- app/Jobs/DatabaseContainerStatusJob.php | 57 -------------- app/Jobs/ProxyContainerStatusJob.php | 87 ---------------------- 3 files changed, 198 deletions(-) delete mode 100644 app/Jobs/ApplicationContainerStatusJob.php delete mode 100644 app/Jobs/DatabaseContainerStatusJob.php delete mode 100644 app/Jobs/ProxyContainerStatusJob.php diff --git a/app/Jobs/ApplicationContainerStatusJob.php b/app/Jobs/ApplicationContainerStatusJob.php deleted file mode 100644 index ae41a5c41..000000000 --- a/app/Jobs/ApplicationContainerStatusJob.php +++ /dev/null @@ -1,54 +0,0 @@ -containerName = generateApplicationContainerName($application->uuid, $pullRequestId); - } - - public function uniqueId(): string - { - return $this->containerName; - } - - public function handle(): void - { - try { - $status = getApplicationContainerStatus(application: $this->application); - if ($this->application->status === 'running' && $status !== 'running') { - // $this->application->environment->project->team->notify(new StatusChanged($this->application)); - } - - if ($this->pullRequestId !== 0) { - $preview = ApplicationPreview::findPreviewByApplicationAndPullId($this->application->id, $this->pullRequestId); - $preview->status = $status; - $preview->save(); - } else { - $this->application->status = $status; - $this->application->save(); - } - } catch (\Throwable $e) { - ray($e->getMessage()); - throw $e; - } - } -} diff --git a/app/Jobs/DatabaseContainerStatusJob.php b/app/Jobs/DatabaseContainerStatusJob.php deleted file mode 100644 index f1d0de301..000000000 --- a/app/Jobs/DatabaseContainerStatusJob.php +++ /dev/null @@ -1,57 +0,0 @@ -containerName = $database->uuid; - } - - public function uniqueId(): string - { - return $this->containerName; - } - - public function handle(): void - { - try { - $status = getContainerStatus( - server: $this->database->destination->server, - container_id: $this->containerName, - throwError: false - ); - - if ($this->database->status === 'running' && $status !== 'running') { - if (data_get($this->database, 'environment.project.team')) { - // $this->database->environment->project->team->notify(new StatusChanged($this->database)); - } - } - if ($this->database->status !== $status) { - $this->database->status = $status; - $this->database->save(); - } - } catch (\Throwable $e) { - send_internal_notification('DatabaseContainerStatusJob failed with: ' . $e->getMessage()); - ray($e->getMessage()); - throw $e; - } - } -} diff --git a/app/Jobs/ProxyContainerStatusJob.php b/app/Jobs/ProxyContainerStatusJob.php deleted file mode 100644 index 6cfd2692f..000000000 --- a/app/Jobs/ProxyContainerStatusJob.php +++ /dev/null @@ -1,87 +0,0 @@ -server = $server; - } - - public function middleware(): array - { - return [new WithoutOverlapping($this->server->uuid)]; - } - - public function uniqueId(): string - { - ray($this->server->uuid); - return $this->server->uuid; - } - - public function handle(): void - { - try { - $proxyType = data_get($this->server, 'proxy.type'); - if ($proxyType === ProxyTypes::NONE->value) { - return; - } - if (is_null($proxyType)) { - if ($this->server->isProxyShouldRun()) { - $this->server->proxy->type = ProxyTypes::TRAEFIK_V2->value; - $this->server->proxy->status = ProxyStatus::EXITED->value; - $this->server->save(); - resolve(StartProxy::class)($this->server); - return; - } - } - - $container = getContainerStatus(server: $this->server, all_data: true, container_id: 'coolify-proxy', throwError: false); - $containerStatus = data_get($container, 'State.Status'); - $databaseContainerStatus = data_get($this->server, 'proxy.status', 'exited'); - - - if ($proxyType !== ProxyTypes::NONE->value) { - if ($containerStatus === 'running') { - $this->server->proxy->status = $containerStatus; - $this->server->save(); - return; - } - if ((is_null($containerStatus) ||$containerStatus !== 'running' || $databaseContainerStatus !== 'running' || ($containerStatus && $databaseContainerStatus !== $containerStatus)) && $this->server->isProxyShouldRun()) { - $this->server->proxy->status = $containerStatus; - $this->server->save(); - resolve(StartProxy::class)($this->server); - return; - } - } - } catch (\Throwable $e) { - if ($e->getCode() === 1) { - $this->server->proxy->status = 'exited'; - $this->server->save(); - } - send_internal_notification('ProxyContainerStatusJob failed with: ' . $e->getMessage()); - ray($e->getMessage()); - throw $e; - } - } -}