Merge branch 'master' of ssh://git.kmlabz.com:2222/birbnetes/storage-service
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
commit
16543b72d8
@ -1,4 +1,4 @@
|
||||
FROM python:3.8-slim
|
||||
FROM python:3.9-slim
|
||||
|
||||
ADD storage_service requirements.txt /storage_service/
|
||||
WORKDIR /storage_service/
|
||||
|
@ -7,3 +7,4 @@ Flask-Classful
|
||||
gunicorn
|
||||
sentry_sdk
|
||||
flask_minio
|
||||
py-healthcheck
|
@ -3,9 +3,10 @@ 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 utils import register_all_error_handlers, storage
|
||||
from utils import register_all_error_handlers, storage, health_database_status
|
||||
|
||||
# import views
|
||||
from views import ObjectView
|
||||
@ -32,6 +33,8 @@ app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1)
|
||||
# init stuff
|
||||
storage.init_app(app)
|
||||
|
||||
health = HealthCheck()
|
||||
|
||||
# register error handlers
|
||||
register_all_error_handlers(app)
|
||||
|
||||
@ -39,6 +42,9 @@ register_all_error_handlers(app)
|
||||
for view in [ObjectView]:
|
||||
view.register(app, trailing_slash=False)
|
||||
|
||||
health.add_check(health_database_status)
|
||||
app.add_url_rule("/healthz", "healthcheck", view_func=lambda: health.run())
|
||||
|
||||
# start debugging if needed
|
||||
if __name__ == "__main__":
|
||||
app.run(debug=True)
|
||||
|
@ -2,3 +2,4 @@
|
||||
from .require_decorators import json_required
|
||||
from .error_handlers import register_all_error_handlers
|
||||
from .storage import storage
|
||||
from .healthchecks import health_database_status
|
23
storage_service/utils/healthchecks.py
Normal file
23
storage_service/utils/healthchecks.py
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from utils import storage
|
||||
|
||||
"""
|
||||
Healthchek functions
|
||||
"""
|
||||
|
||||
__author__ = "@tormakris"
|
||||
__copyright__ = "Copyright 2020, Birbnetes Team"
|
||||
__module_name__ = "healthchecks"
|
||||
__version__text__ = "1"
|
||||
|
||||
|
||||
def health_database_status():
|
||||
is_database_working = True
|
||||
output = 'storage is ok'
|
||||
try:
|
||||
storage.connection.list_buckets()
|
||||
except Exception as e:
|
||||
output = str(e)
|
||||
is_database_working = False
|
||||
return is_database_working, output
|
Loading…
Reference in New Issue
Block a user