mirror of
https://github.com/myronblair/kino-app
synced 2026-07-29 05:54:01 -05:00
Add admin-only service status panel with restart, wired to Docker directly
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""Docker service status/restart for the internal StreamHoard stack."""
|
||||
import docker
|
||||
|
||||
SERVICES = [
|
||||
{"key": "gluetun", "label": "VPN (gluetun)", "container": "streamhoard-gluetun"},
|
||||
{"key": "sonarr", "label": "Sonarr", "container": "streamhoard-sonarr"},
|
||||
{"key": "radarr", "label": "Radarr", "container": "streamhoard-radarr"},
|
||||
{"key": "prowlarr", "label": "Prowlarr", "container": "streamhoard-prowlarr"},
|
||||
{"key": "qbittorrent", "label": "qBittorrent", "container": "streamhoard-qbittorrent"},
|
||||
{"key": "mongo", "label": "Database", "container": "streamhoard-mongo"},
|
||||
{"key": "portainer", "label": "Portainer", "container": "streamhoard-portainer"},
|
||||
]
|
||||
|
||||
_client = None
|
||||
|
||||
|
||||
def _get_client():
|
||||
global _client
|
||||
if _client is None:
|
||||
_client = docker.DockerClient(base_url="unix:///var/run/docker.sock")
|
||||
return _client
|
||||
|
||||
|
||||
def list_service_status():
|
||||
client = _get_client()
|
||||
out = []
|
||||
for svc in SERVICES:
|
||||
try:
|
||||
c = client.containers.get(svc["container"])
|
||||
running = c.status == "running"
|
||||
except docker.errors.NotFound:
|
||||
running = False
|
||||
except Exception:
|
||||
running = False
|
||||
out.append({"key": svc["key"], "label": svc["label"], "running": running})
|
||||
return out
|
||||
|
||||
|
||||
def restart_service(key: str) -> bool:
|
||||
svc = next((s for s in SERVICES if s["key"] == key), None)
|
||||
if not svc:
|
||||
return False
|
||||
client = _get_client()
|
||||
c = client.containers.get(svc["container"])
|
||||
c.restart(timeout=15)
|
||||
return True
|
||||
Reference in New Issue
Block a user