From 10f69f2ea780abd0a197128cb0af7e87a4ecb481 Mon Sep 17 00:00:00 2001 From: Newnius Date: Thu, 26 Dec 2019 19:24:18 +0800 Subject: [PATCH] all in one --- Dockerfile | 2 ++ bootstrap.sh | 8 +++++--- main.py | 4 ---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02ef8c1..d12c9de 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,8 @@ ADD monitor.py /root/monitor.py ADD executor.py /root/executor.py +ADD main.py /root/main.py + WORKDIR /root CMD ["/etc/bootstrap.sh"] \ No newline at end of file diff --git a/bootstrap.sh b/bootstrap.sh index d57b604..74fd927 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -5,8 +5,10 @@ # run nvidia-smi in background to speed up the query and reduce CPU load (why?) nvidia-smi daemon -python3 /root/monitor.py & +#python3 /root/monitor.py & -python3 /root/executor.py & +#python3 /root/executor.py & -sleep infinity \ No newline at end of file +#sleep infinity + +python3 /root/main.py \ No newline at end of file diff --git a/main.py b/main.py index e039dd9..979bbb6 100644 --- a/main.py +++ b/main.py @@ -143,18 +143,14 @@ class MyHandler(BaseHTTPRequestHandler): docker_cmd ]) - print(script) - client = docker.from_env() container = client.containers.get('yao-agent-helper') exit_code, output = container.exec_run(['sh', '-c', script]) msg = {"code": 0, "id": output.decode('utf-8').rstrip('\n')} - print(msg) lock.acquire() pending_tasks[msg['id']] = {'gpus': str(docker_gpus).split(',')} lock.release() - print(msg) if exit_code != 0: msg["code"] = 1 except Exception as e: