瀏覽代碼

Improve handling of stack status, close #11

Louis Lam 1 年之前
父節點
當前提交
c8770a9605
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      backend/stack.ts

+ 5 - 2
backend/stack.ts

@@ -264,15 +264,18 @@ export class Stack {
 
 
     /**
     /**
      * Convert the status string from `docker compose ls` to the status number
      * Convert the status string from `docker compose ls` to the status number
+     * Input Example: "exited(1), running(1)"
      * @param status
      * @param status
      */
      */
     static statusConvert(status : string) : number {
     static statusConvert(status : string) : number {
         if (status.startsWith("created")) {
         if (status.startsWith("created")) {
             return CREATED_STACK;
             return CREATED_STACK;
+        } 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")) {
         } else if (status.startsWith("running")) {
+            // If there is no exited services, there should be only running services
             return RUNNING;
             return RUNNING;
-        } else if (status.startsWith("exited")) {
-            return EXITED;
         } else {
         } else {
             return UNKNOWN;
             return UNKNOWN;
         }
         }