浏览代码

Update docker.py

qiaofeng1227 2 年之前
父节点
当前提交
631189cbf4
共有 1 个文件被更改,包括 9 次插入10 次删除
  1. 9 10
      appmanage/api/utils/docker.py

+ 9 - 10
appmanage/api/utils/docker.py

@@ -9,17 +9,16 @@ from pathlib import Path
 
 
 def get_process_perc(app_name):
 def get_process_perc(app_name):
     
     
-    process_now = "0%"
-    path = "/data/apps/" + app_name + "/.env"
-    app_version_env, app_version = read_env(path, "APP_VERSION")
-    print(app_version)
-    client = docker.from_env()
-    image_name = app_name + ":" + app_version
-    print(resp)
-    resp = client.api.pull(app_name, tags=app_version, stream=True, decode=True)
+    process_now = "pulling"
+    output = "sudo docker image list |grep  " + app_name
+    code = output["code"]
+    if int(code) == 0 and output["result"] != "":
+        process_now = "starting"
+    output = "sudo docker compose ls |grep " + app_name
+    code = output["code"]
+    if int(code) == 0 and output["result"] != "":
+        process_now = "initializing"
 
 
-    for line in resp:
-      print(json.dumps(line, indent=4))
 
 
     return process_now
     return process_now