mirror of
https://github.com/nextcloud/all-in-one.git
synced 2025-12-20 06:26:57 +00:00
Merge pull request #352 from nextcloud/enh/fix-domaincheck-startup
fix domaincheck startup
This commit is contained in:
commit
817df30465
2 changed files with 19 additions and 9 deletions
|
|
@ -27,7 +27,7 @@ class ContainerDefinitionFetcher
|
||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function GetContainerById(string $id): ?Container
|
public function GetContainerById(string $id): Container
|
||||||
{
|
{
|
||||||
$containers = $this->FetchDefinition();
|
$containers = $this->FetchDefinition();
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ class ContainerDefinitionFetcher
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
throw new \Exception("The provided id " . $id . " was not found in the container definition.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -163,22 +163,32 @@ class DockerController
|
||||||
public function StartDomaincheckContainer() : void
|
public function StartDomaincheckContainer() : void
|
||||||
{
|
{
|
||||||
# Don't start if domain is already set
|
# Don't start if domain is already set
|
||||||
if ($this->configurationManager->GetDomain() != '') {
|
if ($this->configurationManager->GetDomain() !== '' || $this->configurationManager->wasStartButtonClicked()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = 'nextcloud-aio-domaincheck';
|
$id = 'nextcloud-aio-domaincheck';
|
||||||
|
|
||||||
$container = $this->containerDefinitionFetcher->GetContainerById($id);
|
$cacheKey = 'domaincheckWasStarted';
|
||||||
// don't start if the domaincheck is already running
|
|
||||||
if ($container->GetIdentifier() === $id && $container->GetRunningState() instanceof RunningState) {
|
$domaincheckContainer = $this->containerDefinitionFetcher->GetContainerById($id);
|
||||||
|
$apacheContainer = $this->containerDefinitionFetcher->GetContainerById(self::TOP_CONTAINER);
|
||||||
|
// Don't start if apache is already running
|
||||||
|
if ($apacheContainer->GetRunningState() instanceof RunningState) {
|
||||||
return;
|
return;
|
||||||
// don't start if apache is already running
|
// Don't start if domaincheck is already running
|
||||||
} elseif ($container->GetIdentifier() === self::TOP_CONTAINER && $container->GetRunningState() instanceof RunningState) {
|
} elseif ($domaincheckContainer->GetRunningState() instanceof RunningState) {
|
||||||
|
$domaincheckWasStarted = apcu_fetch($cacheKey);
|
||||||
|
// Start domaincheck again when 10 minutes are over by not returning here
|
||||||
|
if($domaincheckWasStarted !== false && is_string($domaincheckWasStarted)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->PerformRecursiveContainerStart($id);
|
$this->PerformRecursiveContainerStart($id);
|
||||||
|
|
||||||
|
// Cache the start for 10 minutes
|
||||||
|
apcu_add($cacheKey, '1', 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function StopDomaincheckContainer() : void
|
private function StopDomaincheckContainer() : void
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue