Potentially fixes #1

This commit is contained in:
Neshura 2022-12-10 03:12:08 +01:00
parent 6af8cb3e1b
commit 8426640271
No known key found for this signature in database
GPG key ID: ACDF5B6EBECF6B0A

View file

@ -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;