lemur/lemur/common/health.py

30 lines
682 B
Python
Raw Normal View History

2015-06-22 22:47:27 +02:00
"""
.. module: lemur.common.health
:platform: Unix
:copyright: (c) 2015 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
from flask import Blueprint
from lemur.database import db
from lemur.extensions import sentry
2015-06-22 22:47:27 +02:00
mod = Blueprint('healthCheck', __name__)
2015-07-21 22:06:13 +02:00
2015-06-22 22:47:27 +02:00
@mod.route('/healthcheck')
def health():
try:
if healthcheck(db):
return 'ok'
except Exception:
sentry.captureException()
return 'db check failed'
def healthcheck(db):
with db.engine.connect() as connection:
connection.execute('SELECT 1;')
return True