Skip to content

Commit

Permalink
Merge branch 'pr-add-healthcheck-endpoint-xcp' of https://github.com/…
Browse files Browse the repository at this point in the history
  • Loading branch information
chiguireitor committed Dec 19, 2020
2 parents 90458a4 + 7f7b430 commit 3df04d9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions counterpartylib/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,16 @@ def _set_cors_headers(response):
response.headers['Access-Control-Allow-Methods'] = 'GET, POST, OPTIONS'
response.headers['Access-Control-Allow-Headers'] = 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization'

@app.route('/healthz', methods=['GET'])
def handle_healthz():
msg, code = 'Healthy', 200
try:
latestBlockIndex = backend.getblockcount()
check_database_state(self.db, latestBlockIndex)
except DatabaseError:
msg, code = 'Unhealthy', 503
return flask.Response(msg, code, mimetype='text/plain')

@app.route('/', defaults={'args_path': ''}, methods=['GET', 'POST', 'OPTIONS'])
@app.route('/<path:args_path>', methods=['GET', 'POST', 'OPTIONS'])
# Only require authentication if RPC_PASSWORD is set.
Expand Down

0 comments on commit 3df04d9

Please sign in to comment.