Add some logging for healthchecks
All checks were successful
continuous-integration/drone Build is passing
All checks were successful
continuous-integration/drone Build is passing
This commit is contained in:
parent
4d2497fd0d
commit
6bdd9e0fbf
24
camdetect.py
24
camdetect.py
@ -500,25 +500,15 @@ async def stream_wrapper(request):
|
|||||||
|
|
||||||
@app.route("/readyz")
|
@app.route("/readyz")
|
||||||
async def ready_check(request):
|
async def ready_check(request):
|
||||||
if app.ctx.mask is None:
|
logger.info("Testing if Mongo is accessible")
|
||||||
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
|
|
||||||
try:
|
try:
|
||||||
async for i in app.ctx.coll.find().limit(1):
|
async for i in app.ctx.coll.find().limit(1):
|
||||||
break
|
break
|
||||||
except pymongo.errors.ServerSelectionTimeoutError:
|
except pymongo.errors.ServerSelectionTimeoutError:
|
||||||
return response.text("MongoDB server selection timeout", status=503)
|
return response.text("MongoDB server selection timeout", status=503)
|
||||||
|
|
||||||
# Check if S3 is accessible
|
|
||||||
session = aioboto3.Session()
|
session = aioboto3.Session()
|
||||||
|
logger.info("Testing if S3 is writable")
|
||||||
async with session.resource("s3",
|
async with session.resource("s3",
|
||||||
aws_access_key_id=AWS_ACCESS_KEY_ID,
|
aws_access_key_id=AWS_ACCESS_KEY_ID,
|
||||||
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
|
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")
|
await bucket.upload_fileobj(io.BytesIO(b"test"), "test")
|
||||||
return response.text("OK")
|
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")
|
@app.route("/event")
|
||||||
async def wrapper_stream_event(request):
|
async def wrapper_stream_event(request):
|
||||||
|
Loading…
Reference in New Issue
Block a user