This commit is contained in:
Andras Bacsai
2023-09-21 21:30:13 +02:00
parent 6b75ff7de4
commit e1a1490911
10 changed files with 139 additions and 40 deletions

View File

@@ -208,3 +208,32 @@ function replaceVariables($variable)
{
return $variable->replaceFirst('$', '')->replaceFirst('{', '')->replaceLast('}', '');
}
function serviceStatus(Service $service)
{
$foundRunning = false;
$isDegraded = false;
$applications = $service->applications;
$databases = $service->databases;
foreach ($applications as $application) {
if ($application->status === 'running') {
$foundRunning = true;
} else {
$isDegraded = true;
}
}
foreach ($databases as $database) {
if ($database->status === 'running') {
$foundRunning = true;
} else {
$isDegraded = true;
}
}
if ($foundRunning && !$isDegraded) {
return 'running';
} else if ($foundRunning && $isDegraded) {
return 'degraded';
} else if (!$foundRunning && $isDegraded) {
return 'exited';
}
}