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) 2018 by Netflix Inc., see AUTHORS for more
2015-06-22 22:47:27 +02:00
: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
2019-05-16 16:57:02 +02:00
mod = Blueprint("healthCheck", __name__)
2015-06-22 22:47:27 +02:00
2015-07-21 22:06:13 +02:00
2019-05-16 16:57:02 +02:00
@mod.route("/healthcheck")
2015-06-22 22:47:27 +02:00
def health():
try:
if healthcheck(db):
2019-05-16 16:57:02 +02:00
return "ok"
except Exception:
sentry.captureException()
2019-05-16 16:57:02 +02:00
return "db check failed"
def healthcheck(db):
with db.engine.connect() as connection:
2019-05-16 16:57:02 +02:00
connection.execute("SELECT 1;")
return True