Add some logging for healthchecks
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Lauri Võsandi 2022-12-02 23:03:58 +02:00
parent 4d2497fd0d
commit 6bdd9e0fbf

View File

@ -500,25 +500,15 @@ async def stream_wrapper(request):
@app.route("/readyz")
async def ready_check(request):
if app.ctx.mask is None:
return response.text("Not enough frames", status=503)
return response.text("OK")
@app.route("/healthz")
async def health_check(request):
if app.ctx.mask is None:
return response.text("Not enough frames", status=503)
# Check if Mongo is accessible
logger.info("Testing if Mongo is accessible")
try:
async for i in app.ctx.coll.find().limit(1):
break
except pymongo.errors.ServerSelectionTimeoutError:
return response.text("MongoDB server selection timeout", status=503)
# Check if S3 is accessible
session = aioboto3.Session()
logger.info("Testing if S3 is writable")
async with session.resource("s3",
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
@ -527,6 +517,16 @@ async def health_check(request):
await bucket.upload_fileobj(io.BytesIO(b"test"), "test")
return response.text("OK")
print("Checking if there are any frames received")
if app.ctx.mask is None:
return response.text("Not enough frames", status=503)
@app.route("/healthz")
async def health_check(request):
if app.ctx.mask is None:
return response.text("Not enough frames", status=503)
@app.route("/event")
async def wrapper_stream_event(request):