Show each container's fallback tier on the Monitor board
The row's left border carries it rather than the status dot, which already means running or stopped.
This commit is contained in:
@@ -19,7 +19,8 @@
|
||||
//
|
||||
// EXPORTS
|
||||
// vv_container_webui() WebUI URL for one container, or empty
|
||||
// vv_get_docker_folders() folder grouping in the legacy shape
|
||||
// vv_container_tier_map() container name (lowercased) => fallback tier 1-4
|
||||
// vv_get_docker_folders() folder grouping in the legacy shape, each container carrying 'tier'
|
||||
//
|
||||
// CONFIGURATION
|
||||
// Inherits everything from docker.php — see that file's CONFIGURATION block.
|
||||
@@ -54,11 +55,31 @@ function vv_container_webui(string $name, array $portMap): string {
|
||||
return $url;
|
||||
}
|
||||
|
||||
// Fallback tier for each container, from FALLBACK_<ME>_TIER1..4 in THIS host's own conf —
|
||||
// that list is what the partner starts for us, so a lower tier means it comes back sooner.
|
||||
// Keyed lowercase because conf spelling and docker's spelling of a name need not match.
|
||||
function vv_container_tier_map(): array {
|
||||
$me = strtoupper(vv_detect_host());
|
||||
if ($me === 'UNKNOWN') return [];
|
||||
$raw = vv_read_host_conf_raw(strtolower($me));
|
||||
if ($raw === '') return [];
|
||||
|
||||
$map = [];
|
||||
for ($t = 1; $t <= 4; $t++) {
|
||||
foreach (vv_parse_conf_list($raw, "FALLBACK_{$me}_TIER{$t}") as $name) {
|
||||
$key = strtolower(trim($name));
|
||||
if ($key !== '' && !isset($map[$key])) $map[$key] = $t; // lowest tier wins a duplicate
|
||||
}
|
||||
}
|
||||
return $map;
|
||||
}
|
||||
|
||||
function vv_get_docker_folders(): array {
|
||||
// Varaverk's own docker_folders.json is the primary store (see include/docker.php) —
|
||||
// reading folder.view3's mirror directly here left this widget empty on any host
|
||||
// without that optional third-party plugin installed.
|
||||
$folderData = vv_dk_read_json();
|
||||
$tierMap = vv_container_tier_map();
|
||||
|
||||
// One docker ps call: names, status, port mappings
|
||||
$raw = shell_exec("docker ps -a --format '{{.Names}}\t{{.Status}}\t{{.Ports}}' 2>/dev/null") ?? '';
|
||||
@@ -92,6 +113,7 @@ function vv_get_docker_folders(): array {
|
||||
'running' => $running,
|
||||
'status' => $status,
|
||||
'webui' => vv_container_webui($cname, $portMap),
|
||||
'tier' => $tierMap[strtolower($cname)] ?? null,
|
||||
];
|
||||
}
|
||||
usort($containers, fn($a, $b) => $b['running'] <=> $a['running'] ?: strcmp($a['name'], $b['name']));
|
||||
@@ -114,6 +136,7 @@ function vv_get_docker_folders(): array {
|
||||
'running' => $running,
|
||||
'status' => $status,
|
||||
'webui' => vv_container_webui($cname, $portMap),
|
||||
'tier' => $tierMap[strtolower($cname)] ?? null,
|
||||
];
|
||||
}
|
||||
usort($ungrouped, fn($a, $b) => strcmp($a['name'], $b['name']));
|
||||
|
||||
Reference in New Issue
Block a user