report configured containers Docker never lists as stopped

A name in SERVICES_ALIASES with no matching container (typo or deleted)
produced no `docker ps -a` line, so it silently vanished from the
dashboard instead of showing as a problem. Track which configured names
were seen and append the leftovers as stopped, logging edge-triggered so
a persistent typo doesn't reprint every 2s poll.

Also corrects the kcmonitor container name and refreshes the README
service list.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-24 15:46:01 +09:00
parent a20a8f3552
commit 8a9e8ba7ff
2 changed files with 24 additions and 2 deletions
+23 -1
View File
@@ -71,8 +71,13 @@ SERVICES_ALIASES = {
"frpc-ssh": "frpc (ssh)",
"jellyfin": "jellyfin",
"kancolle-start2-server": "kc-start2",
"kancolle": "kc-monitor",
"kancolle-kcmonitor": "kc-monitor",
}
# Configured names Docker didn't report, so a typo doesn't reprint every 2s
_missing_containers: set[str] = set()
def _get_docker_services() -> list[dict]:
"""Query Docker for real container statuses with ternary status model."""
try:
@@ -86,7 +91,10 @@ def _get_docker_services() -> list[dict]:
if result.returncode != 0:
return []
global _missing_containers
services = []
seen = set()
for line in result.stdout.strip().splitlines():
parts = line.split("\t", 1)
if len(parts) != 2:
@@ -102,6 +110,20 @@ def _get_docker_services() -> list[dict]:
else:
status = "stopped"
services.append({"name": SERVICES_ALIASES[name], "status": status})
seen.add(name)
# A configured name Docker never reported is either a typo or a deleted
# container — show it as stopped instead of dropping it off the dashboard
missing = set(SERVICES_ALIASES) - seen
for name in sorted(missing):
services.append({"name": SERVICES_ALIASES[name], "status": "stopped"})
if missing != _missing_containers:
for name in sorted(missing - _missing_containers):
print(f"No container named {name!r} — reporting as stopped")
for name in sorted(_missing_containers - missing):
print(f"Container {name!r} is back")
_missing_containers = missing
# Sort: warnings first, then stopped, then running (problems float to top)
order = {"warning": 0, "stopped": 1, "running": 2}