From c8770a96055d5f37502248099bc4ea4aec94b2b4 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 20 Nov 2023 00:52:33 +0800 Subject: [PATCH] Improve handling of stack status, close #11 --- backend/stack.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/stack.ts b/backend/stack.ts index c595efb..922dad8 100644 --- a/backend/stack.ts +++ b/backend/stack.ts @@ -264,15 +264,18 @@ export class Stack { /** * Convert the status string from `docker compose ls` to the status number + * Input Example: "exited(1), running(1)" * @param status */ static statusConvert(status : string) : number { if (status.startsWith("created")) { return CREATED_STACK; - } else if (status.startsWith("running")) { - return RUNNING; - } else if (status.startsWith("exited")) { + } else if (status.includes("exited")) { + // If one of the service is exited, we consider the stack is exited return EXITED; + } else if (status.startsWith("running")) { + // If there is no exited services, there should be only running services + return RUNNING; } else { return UNKNOWN; }