Added health check feature to find faulty components

This commit is contained in:
Martin Schett
2020-12-06 18:53:29 +01:00
parent ddf0cbf2d7
commit 08b30bb9cd
7 changed files with 67 additions and 3 deletions
@@ -5,6 +5,19 @@ import dropbox
class DropboxService:
@staticmethod
def check() -> bool:
try:
dbx = dropbox.Dropbox(settings.DROPBOX_OAUTH2_ACCESS_TOKEN)
result = dbx.check_user(query=u'Hello')
if not result.result == 'Hello':
print("String does not match")
return False
except:
return False
return True
@staticmethod
def create_file(filename: str, file: bytes) -> bool:
"""Create / save (or overwrite) an file on the dropbox storage.
@@ -5,6 +5,18 @@ from django.conf import settings
class MinioService:
@staticmethod
def check() -> bool:
print("Checking MinIO availability")
try:
url= settings.AWS_HOST
r = requests.put(url)
if not (r.status_code >= 200 and r.status_code < 500):
return False
except:
return False
return True
@staticmethod
def create_file(filename: str, file: bytes) -> bool:
"""Create / save (or overwrite) an file on the minio storage.
@@ -5,6 +5,15 @@ from app_be.services.hashservice import create_sha512
class MongoDBService:
@staticmethod
def check() -> bool:
try:
instance = MongoManager.getInstance()
instance.AIC
except:
return False
return True
@staticmethod
def getAll():
instance = MongoManager.getInstance()