diff --git a/Dockerfile b/Dockerfile index d12c9de..d6329c7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,11 +14,7 @@ RUN pip3 install docker kafka psutil ADD bootstrap.sh /etc/bootstrap.sh -ADD monitor.py /root/monitor.py - -ADD executor.py /root/executor.py - -ADD main.py /root/main.py +ADD agent.py /root/agent.py WORKDIR /root diff --git a/main.py b/agent.py similarity index 99% rename from main.py rename to agent.py index 979bbb6..6fe0507 100644 --- a/main.py +++ b/agent.py @@ -94,6 +94,8 @@ class MyHandler(BaseHTTPRequestHandler): 'hostname': container.attrs['Config']['Hostname'], 'state': container.attrs['State'] } + if container_id in pending_tasks: + status['status'] = 'Ready' if status['command'] is not None: status['command'] = ' '.join(container.attrs['Config']['Cmd']) msg = {'code': 0, 'status': status} @@ -311,18 +313,13 @@ def listener(): server.socket.close() -def main(): - t1 = Thread(target=report) - t2 = Thread(target=listener) - t1.start() - t2.start() - print("started") - while True: - pass - - if __name__ == '__main__': os.environ["TZ"] = 'Asia/Shanghai' if hasattr(time, 'tzset'): time.tzset() - main() + t1 = Thread(target=report) + t2 = Thread(target=listener) + t1.start() + t2.start() + while True: + pass diff --git a/bootstrap.sh b/bootstrap.sh index 74fd927..c1e178f 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,14 +1,6 @@ #!/usr/bin/env bash -# TODO: monitor the processes - # run nvidia-smi in background to speed up the query and reduce CPU load (why?) nvidia-smi daemon -#python3 /root/monitor.py & - -#python3 /root/executor.py & - -#sleep infinity - -python3 /root/main.py \ No newline at end of file +python3 /root/agent.py \ No newline at end of file