Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport/stable30/430/manual #434

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/Service/AppAPIService.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public function __construct(
private readonly DockerActions $dockerActions,
private readonly ManualActions $manualActions,
private readonly AppAPICommonService $commonService,
private readonly DaemonConfigService $daemonConfigService,
) {
$this->client = $clientService->newClient();
}
Expand Down Expand Up @@ -556,7 +557,13 @@ public function getExAppDomain(ExApp $exApp): string {
*/
public function enableExApp(ExApp $exApp): bool {
if ($this->exAppService->enableExAppInternal($exApp)) {
$exAppEnabled = $this->requestToExApp($exApp, '/enabled?enabled=1', null, 'PUT', options: ['timeout' => 30]);
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()));
}

$exAppEnabled = $this->requestToExApp($exApp, '/enabled?enabled=1', null, 'PUT', options: ['timeout' => 60]);
if ($exAppEnabled instanceof IResponse) {
$response = json_decode($exAppEnabled->getBody(), true);
if (!empty($response['error'])) {
Expand All @@ -579,7 +586,7 @@ public function enableExApp(ExApp $exApp): bool {
*/
public function disableExApp(ExApp $exApp): bool {
$result = true;
$exAppDisabled = $this->requestToExApp($exApp, '/enabled?enabled=0', null, 'PUT', options: ['timeout' => 30]);
$exAppDisabled = $this->requestToExApp($exApp, '/enabled?enabled=0', null, 'PUT', options: ['timeout' => 60]);
if ($exAppDisabled instanceof IResponse) {
$response = json_decode($exAppDisabled->getBody(), true);
if (isset($response['error']) && strlen($response['error']) !== 0) {
Expand All @@ -590,6 +597,11 @@ public function disableExApp(ExApp $exApp): bool {
$this->logger->error(sprintf('Failed to disable ExApp %s. Error: %s', $exApp->getAppid(), $exAppDisabled['error']));
$result = false;
}
if ($exApp->getAcceptsDeployId() === $this->dockerActions->getAcceptsDeployId()) {
$daemonConfig = $this->daemonConfigService->getDaemonConfigByName($exApp->getDaemonConfigName());
$this->dockerActions->initGuzzleClient($daemonConfig);
$this->dockerActions->stopContainer($this->dockerActions->buildDockerUrl($daemonConfig), $this->dockerActions->buildExAppContainerName($exApp->getAppid()));
}
$this->exAppService->disableExAppInternal($exApp);
return $result;
}
Expand Down
Loading