Add Check of DB connections on healthcheck URL (#812)
This commit is contained in:
parent
f9b388c658
commit
f6b5012f56
|
@ -7,10 +7,21 @@
|
||||||
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
||||||
"""
|
"""
|
||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
|
from lemur.database import db
|
||||||
|
|
||||||
mod = Blueprint('healthCheck', __name__)
|
mod = Blueprint('healthCheck', __name__)
|
||||||
|
|
||||||
|
|
||||||
@mod.route('/healthcheck')
|
@mod.route('/healthcheck')
|
||||||
def health():
|
def health():
|
||||||
|
try:
|
||||||
|
if healthcheck(db):
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
except:
|
||||||
|
return 'db check failed'
|
||||||
|
|
||||||
|
|
||||||
|
def healthcheck(db):
|
||||||
|
with db.engine.connect() as connection:
|
||||||
|
connection.execute('SELECT 1;')
|
||||||
|
return True
|
||||||
|
|
Loading…
Reference in New Issue