feat: add Docker HEALTHCHECK (issue #69)

This commit is contained in:
DoroWu 2018-04-22 23:00:48 +08:00
parent ba3e2c2595
commit e2d659d992
3 changed files with 9 additions and 3 deletions

View file

@ -90,4 +90,5 @@ EXPOSE 80
WORKDIR /root
ENV HOME=/home/ubuntu \
SHELL=/bin/bash
HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://127.0.0.1/api/health
ENTRYPOINT ["/startup.sh"]

View file

@ -8,6 +8,7 @@ from flask import (
request,
Response,
jsonify,
abort,
)
from gevent import subprocess as gsp, spawn, sleep
from geventwebsocket.exceptions import WebSocketError
@ -35,6 +36,13 @@ def apistate():
})
@app.route('/api/health')
def apihealth():
if state.health:
return 'success'
abort(503, 'unhealthy')
@app.route('/api/reset')
def reset():
if 'w' in request.args and 'h' in request.args:

View file

@ -27,9 +27,6 @@ class State(object):
self._event.set()
def _update_health(self):
if self._health:
return
health = True
output = gsp.check_output(['supervisorctl', 'status'])
for line in output.strip().split('\n'):