[health] Adding DB check to /health (#4062)

This commit is contained in:
John Bodley 2017-12-16 11:59:41 +13:00 committed by Maxime Beauchemin
parent c21513fb8c
commit 6081f7161a

View File

@ -28,6 +28,7 @@ import pandas as pd
import sqlalchemy as sqla
from sqlalchemy import create_engine
from sqlalchemy.engine.url import make_url
from sqlalchemy.exc import OperationalError
from unidecode import unidecode
from werkzeug.routing import BaseConverter
from werkzeug.utils import secure_filename
@ -654,6 +655,11 @@ appbuilder.add_view(
@app.route('/health')
def health():
try:
db.session.execute('SELECT 1')
except OperationalError:
return Response('BAD', status=500)
return 'OK'