mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-16 01:13:47 +00:00
add oj-backend health check
This commit is contained in:
parent
ee89df9ff2
commit
7cb8a83bba
@ -5,6 +5,8 @@ ENV OJ_ENV production
|
||||
ADD . /app
|
||||
WORKDIR /app
|
||||
|
||||
HEALTHCHECK --interval=5s --retries=3 CMD python2 /app/deploy/health_check.py
|
||||
|
||||
RUN printf "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.6/community/\nhttps://mirrors.tuna.tsinghua.edu.cn/alpine/v3.6/main/" > /etc/apk/repositories && \
|
||||
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 -i https://pypi.tuna.tsinghua.edu.cn/simple && \
|
||||
@ -12,4 +14,5 @@ RUN printf "https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.6/community/\nhttps:/
|
||||
RUN curl -L $(curl -s https://api.github.com/repos/QingdaoU/OnlineJudgeFE/releases/latest | grep /dist.zip | cut -d '"' -f 4) -o dist.zip && \
|
||||
unzip dist.zip && \
|
||||
rm dist.zip
|
||||
|
||||
CMD sh /app/deploy/run.sh
|
||||
|
11
deploy/health_check.py
Normal file
11
deploy/health_check.py
Normal file
@ -0,0 +1,11 @@
|
||||
import xmlrpclib
|
||||
|
||||
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))
|
||||
except Exception as e:
|
||||
print(e.with_traceback())
|
||||
exit(1)
|
Loading…
x
Reference in New Issue
Block a user