Skip to content

Commit

Permalink
[health] Adding DB check to /health (apache#4062)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley authored and mistercrunch committed Dec 15, 2017
1 parent 5e086bc commit fd7ddd3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions superset/views/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
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
Expand Down Expand Up @@ -654,6 +655,11 @@ class LogModelView(SupersetModelView):

@app.route('/health')
def health():
try:
db.session.execute('SELECT 1')
except OperationalError:
return Response('BAD', status=500)

return 'OK'


Expand Down

0 comments on commit fd7ddd3

Please sign in to comment.