Merge branch 'master' of ssh://git.kmlabz.com:2222/birbnetes/model-service
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
commit
5eb2e4e007
@ -3,11 +3,12 @@ import sentry_sdk
|
||||
from sentry_sdk.integrations.flask import FlaskIntegration
|
||||
from flask import Flask
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
from healthcheck import HealthCheck
|
||||
|
||||
# import stuff
|
||||
from model import db
|
||||
|
||||
from utils import register_all_error_handlers, storage
|
||||
from utils import register_all_error_handlers, storage, health_database_status
|
||||
|
||||
# import views
|
||||
from views import SVMView, CNNView, RootView
|
||||
@ -23,6 +24,8 @@ if Config.SENTRY_DSN:
|
||||
sentry_sdk.init(
|
||||
dsn=Config.SENTRY_DSN,
|
||||
integrations=[FlaskIntegration()],
|
||||
_experiments={"auto_enabling_integrations": True},
|
||||
traces_sample_rate=1.0,
|
||||
send_default_pii=True,
|
||||
release=Config.RELEASE_ID,
|
||||
environment=Config.RELEASEMODE
|
||||
@ -38,6 +41,7 @@ app.config.from_object(Config)
|
||||
# initialize stuff
|
||||
db.init_app(app)
|
||||
storage.init_app(app)
|
||||
health = HealthCheck()
|
||||
|
||||
|
||||
@app.before_first_request
|
||||
@ -62,6 +66,9 @@ tracing = FlaskTracing(initialize_tracer, True, app)
|
||||
for view in [SVMView, CNNView, RootView]:
|
||||
view.register(app, trailing_slash=False, route_prefix='/model')
|
||||
|
||||
health.add_check(health_database_status)
|
||||
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())
|
||||
|
||||
# start debuggig if needed
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
|
@ -2,3 +2,4 @@
|
||||
from .require_decorators import json_required, multipart_required
|
||||
from .error_handlers import register_all_error_handlers
|
||||
from .storage import storage, ensure_buckets
|
||||
from .healthckecks import health_database_status
|
23
model_service/utils/healthckecks.py
Normal file
23
model_service/utils/healthckecks.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from model import db
|
||||
|
||||
"""
|
||||
Healthchek functions
|
||||
"""
|
||||
|
||||
__author__ = "@tormakris"
|
||||
__copyright__ = "Copyright 2020, Birbnetes Team"
|
||||
__module_name__ = "healthchecks"
|
||||
__version__text__ = "1"
|
||||
|
||||
|
||||
def health_database_status():
|
||||
is_database_working = True
|
||||
output = 'database is ok'
|
||||
try:
|
||||
db.session.execute('SELECT 1')
|
||||
except Exception as e:
|
||||
output = str(e)
|
||||
is_database_working = False
|
||||
return is_database_working, output
|
@ -11,6 +11,7 @@ marshmallow-enum
|
||||
psycopg2-binary
|
||||
flask_minio
|
||||
sentry-sdk
|
||||
py-healthcheck
|
||||
|
||||
cython
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user