Browse Source

docker features 2

master
gsd 1 year ago
parent
commit
dcded7307f
  1. 22
      ext/python-docker-client/dockerclient.py

22
ext/python-docker-client/dockerclient.py

@ -65,8 +65,6 @@ class Client:
s = await c.stats(stream=False)
s = s[0]
print(s)
cpu_delta = s['cpu_stats']['cpu_usage']['total_usage'] - s['precpu_stats']['cpu_usage']['total_usage']
system_cpu_delta = s['cpu_stats']['system_cpu_usage'] - s['precpu_stats']['system_cpu_usage']
@ -110,12 +108,20 @@ if __name__ == "__main__":
loop = asyncio.get_event_loop()
print("Pre setup stage, get servers list...")
loop.run_until_complete(c.request_srvs())
if c.servers.__len__() == 0:
print("Backent not respond, or server list not setup! Exit after 5 seconds...")
loop.run_until_complete(asyncio.sleep(5))
try_count = 5
while try_count:
try_count -= 1
loop.run_until_complete(c.request_srvs())
if c.servers.__len__() == 0:
print("Backend not respond, or server list not setup! Try again after 5 seconds...")
loop.run_until_complete(asyncio.sleep(5))
if try_count == 0:
print("Exit cannot get backend")
sys.exit(1)
else:
print(f"Found {c.servers.__len__()} servers!")
print(f"Found {c.servers.__len__()} servers!")
loop.run_until_complete(c.loop(int(os.getenv("TIMEOUT", "5"))))
Loading…
Cancel
Save