瀏覽代碼

[FIX] sleep time to load correct status

Gogs 7 年之前
父節點
當前提交
c95c7e34a9
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      api/utils/docker_api.py

+ 10 - 0
api/utils/docker_api.py

@@ -3,6 +3,7 @@ from __future__ import unicode_literals
 from django.conf import settings
 from docker import DockerClient
 from docker.errors import DockerException, NotFound, APIError
+import time
 
 '''
 '''
@@ -67,6 +68,9 @@ def start_container(id=None):
     try:
         container = client.containers.get(id)
         container.start()
+
+        time.sleep(1)
+
         container.reload()
 
         return {
@@ -96,6 +100,9 @@ def restart_container(id=None):
     try:
         container = client.containers.get(id)
         container.restart()
+
+        time.sleep(1)
+
         container.reload()
 
         return {
@@ -125,6 +132,9 @@ def stop_container(id=None):
     try:
         container = client.containers.get(id)
         container.stop()
+
+        time.sleep(1)
+
         container.reload()
 
         return {