diff --git a/Dockerfile b/Dockerfile index f66305b3..02b15643 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,7 +5,7 @@ ENV OJ_ENV production ADD . /app WORKDIR /app -HEALTHCHECK --interval=5s --retries=3 CMD python2 /app/deploy/health_check.py +HEALTHCHECK --interval=5s --retries=3 CMD python3 /app/deploy/health_check.py RUN apk add --update --no-cache build-base nginx openssl curl unzip supervisor jpeg-dev zlib-dev postgresql-dev freetype-dev && \ pip install --no-cache-dir -r /app/deploy/requirements.txt && \ diff --git a/deploy/health_check.py b/deploy/health_check.py index f5065a25..472d9e84 100644 --- a/deploy/health_check.py +++ b/deploy/health_check.py @@ -1,11 +1,11 @@ -import xmlrpclib +import xmlrpc.client if __name__ == "__main__": try: - server = xmlrpclib.Server("http://localhost:9005/RPC2") - info = server.supervisor.getAllProcessInfo() - error_states = list(filter(lambda x: x["state"] != 20, info)) - exit(len(error_states)) + with xmlrpc.client.ServerProxy("http://localhost:9005/RPC2") as server: + info = server.supervisor.getAllProcessInfo() + error_states = list(filter(lambda x: x["state"] != 20, info)) + exit(len(error_states)) except Exception as e: print(e.with_traceback()) exit(1)