From 0208684b509220f61251dc3d8a387aa5f2aa324f Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 20 Nov 2023 00:15:37 +0800 Subject: [PATCH] Update a stopped stack, will no longer start the stack --- backend/stack.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/backend/stack.ts b/backend/stack.ts index fde543a..c595efb 100644 --- a/backend/stack.ts +++ b/backend/stack.ts @@ -174,6 +174,17 @@ export class Stack { return exitCode; } + updateStatus() { + let statusList = Stack.getStatusList(); + let status = statusList.get(this.name); + + if (status) { + this._status = status; + } else { + this._status = UNKNOWN; + } + } + static getStackList(server : DockgeServer, useCacheForManaged = false) : Map { let stacksDir = server.stacksDir; let stackList : Map; @@ -322,6 +333,14 @@ export class Stack { if (exitCode !== 0) { throw new Error("Failed to pull, please check the terminal output for more information."); } + + // If the stack is not running, we don't need to restart it + this.updateStatus(); + log.debug("update", "Status: " + this.status); + if (this.status !== RUNNING) { + return exitCode; + } + exitCode = await Terminal.exec(this.server, socket, terminalName, "docker", [ "compose", "up", "-d", "--remove-orphans" ], this.path); if (exitCode !== 0) { throw new Error("Failed to restart, please check the terminal output for more information.");