From 8426640271ed5839d284f1aacf33dc87f0defb67 Mon Sep 17 00:00:00 2001 From: Neshura Date: Sat, 10 Dec 2022 03:12:08 +0100 Subject: [PATCH] Potentially fixes #1 --- pages/services.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pages/services.tsx b/pages/services.tsx index 251be44..b906318 100644 --- a/pages/services.tsx +++ b/pages/services.tsx @@ -111,15 +111,16 @@ function getStatus(containers: Dockerode.ContainerInfo[], entry: Service) { else if (entry.type === "docker") { entry.status = ServiceStatus.offline; // Loop over every found container and compare to the entry provided - containers.forEach((element: Dockerode.ContainerInfo) => { - element.Names.forEach((containerName: string) => { - if (containerName.startsWith("/")) { - containerName = containerName.substring(1); - } - if (containerName === entry.docker_container_name) { + containers.forEach((container: Dockerode.ContainerInfo) => { + console.log(container) + if (container.Names.includes("/" + entry.docker_container_name) || container.Names.includes(entry.docker_container_name)) { + if (container.State === "running") { entry.status = ServiceStatus.online; } - }); + else { + entry.status = ServiceStatus.offline; + } + } if (entry.docker_container_name == null) { console.log("MISSING DOCKER CONTAINER NAME FOR " + entry.name); entry.status = ServiceStatus.error;