From 646c40bdacfec4058bf689c51c6d3500b8b012b5 Mon Sep 17 00:00:00 2001 From: bigcat88 Date: Fri, 8 Nov 2024 11:52:27 +0200 Subject: [PATCH] Manual backport of #436 --- lib/Service/AppAPIService.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/Service/AppAPIService.php b/lib/Service/AppAPIService.php index 5618c735..de5deb2a 100644 --- a/lib/Service/AppAPIService.php +++ b/lib/Service/AppAPIService.php @@ -560,7 +560,23 @@ public function enableExApp(ExApp $exApp): bool { if ($exApp->getAcceptsDeployId() === $this->dockerActions->getAcceptsDeployId()) { $daemonConfig = $this->daemonConfigService->getDaemonConfigByName($exApp->getDaemonConfigName()); $this->dockerActions->initGuzzleClient($daemonConfig); - $this->dockerActions->startContainer($this->dockerActions->buildDockerUrl($daemonConfig), $this->dockerActions->buildExAppContainerName($exApp->getAppid())); + $containerName = $this->dockerActions->buildExAppContainerName($exApp->getAppid()); + $this->dockerActions->startContainer($this->dockerActions->buildDockerUrl($daemonConfig), $containerName); + if (!$this->dockerActions->waitTillContainerStart($containerName, $daemonConfig)) { + $this->logger->error(sprintf('ExApp %s container startup failed.', $exApp->getAppid())); + return false; + } + if (!$this->dockerActions->healthcheckContainer($containerName, $daemonConfig, true)) { + $this->logger->error(sprintf('ExApp %s container healthcheck failed.', $exApp->getAppid())); + return false; + } + } + + $auth = []; + $exAppRootUrl = $this->getExAppUrl($exApp, $exApp->getPort(), $auth); + if (!$this->heartbeatExApp($exAppRootUrl, $auth, $exApp->getAppid())) { + $this->logger->error(sprintf('ExApp %s heartbeat failed.', $exApp->getAppid())); + return false; } $exAppEnabled = $this->requestToExApp($exApp, '/enabled?enabled=1', null, 'PUT', options: ['timeout' => 60]);