fix public function service.php
This commit is contained in:
@@ -31,4 +31,4 @@ class StopService
|
|||||||
return $e->getMessage();
|
return $e->getMessage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,20 +121,25 @@ class Service extends BaseModel
|
|||||||
return $this->morphToMany(Tag::class, 'taggable');
|
return $this->morphToMany(Tag::class, 'taggable');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContainersToStop(bool $previewDeployments = false): array
|
public function getContainersToStop(): array
|
||||||
{
|
{
|
||||||
$containers = $previewDeployments
|
$containersToStop = [];
|
||||||
? getCurrentApplicationContainerStatus($this->destination->server, $this->id, includePullrequests: true)
|
$applications = $this->applications()->get();
|
||||||
: getCurrentApplicationContainerStatus($this->destination->server, $this->id, 0);
|
foreach ($applications as $application) {
|
||||||
|
$containersToStop[] = "{$application->name}-{$this->uuid}";
|
||||||
return $containers->pluck('Names')->toArray();
|
}
|
||||||
|
$dbs = $this->databases()->get();
|
||||||
|
foreach ($dbs as $db) {
|
||||||
|
$containersToStop[] = "{$db->name}-{$this->uuid}";
|
||||||
|
}
|
||||||
|
return $containersToStop;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stopContainers(array $containerNames, $server, int $timeout = 600)
|
public function stopContainers(array $containerNames, $server, int $timeout = 300)
|
||||||
{
|
{
|
||||||
$processes = [];
|
$processes = [];
|
||||||
foreach ($containerNames as $containerName) {
|
foreach ($containerNames as $containerName) {
|
||||||
$processes[$containerName] = $this->stopContainer($containerName, $server, $timeout);
|
$processes[$containerName] = $this->stopContainer($containerName, $timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startTime = time();
|
$startTime = time();
|
||||||
@@ -142,7 +147,7 @@ class Service extends BaseModel
|
|||||||
$finishedProcesses = array_filter($processes, function ($process) {
|
$finishedProcesses = array_filter($processes, function ($process) {
|
||||||
return !$process->running();
|
return !$process->running();
|
||||||
});
|
});
|
||||||
foreach ($finishedProcesses as $containerName => $process) {
|
foreach (array_keys($finishedProcesses) as $containerName) {
|
||||||
unset($processes[$containerName]);
|
unset($processes[$containerName]);
|
||||||
$this->removeContainer($containerName, $server);
|
$this->removeContainer($containerName, $server);
|
||||||
}
|
}
|
||||||
@@ -156,7 +161,7 @@ class Service extends BaseModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function stopContainer(string $containerName, $server, int $timeout): InvokedProcess
|
public function stopContainer(string $containerName, int $timeout): InvokedProcess
|
||||||
{
|
{
|
||||||
return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
|
return Process::timeout($timeout)->start("docker stop --time=$timeout $containerName");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user