Reorder readiness check
This commit is contained in:
parent
eebd2f3d96
commit
e54ad1ddb7
19
camdetect.py
19
camdetect.py
@ -484,6 +484,16 @@ 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)
|
||||
|
||||
# Check 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()
|
||||
async with session.resource("s3",
|
||||
@ -492,15 +502,6 @@ async def ready_check(request):
|
||||
endpoint_url=S3_ENDPOINT_URL) as s3:
|
||||
bucket = await s3.Bucket(S3_BUCKET_NAME)
|
||||
await bucket.upload_fileobj(io.BytesIO(b"test"), "test")
|
||||
|
||||
# Check 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)
|
||||
if app.ctx.mask is None:
|
||||
return response.text("Not enough frames", status=503)
|
||||
return response.text("OK")
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user