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
|
2017-05-23 02:15:41 +02:00
|
|
|
from lemur.database import db
|
2017-10-24 23:04:51 +02:00
|
|
|
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():
|
2017-05-23 02:15:41 +02:00
|
|
|
try:
|
|
|
|
if healthcheck(db):
|
|
|
|
return 'ok'
|
2017-10-24 23:04:51 +02:00
|
|
|
except Exception:
|
|
|
|
sentry.captureException()
|
2017-05-23 02:15:41 +02:00
|
|
|
return 'db check failed'
|
|
|
|
|
|
|
|
|
|
|
|
def healthcheck(db):
|
|
|
|
with db.engine.connect() as connection:
|
|
|
|
connection.execute('SELECT 1;')
|
|
|
|
return True
|