Add readiness check for S3

master
Lauri Võsandi 7 months ago
parent 3472e494f4
commit 3d1aa220dd
  1. 10
      camdetect.py

@ -483,6 +483,16 @@ async def stream_wrapper(request):
@app.route("/readyz")
async def ready_check(request):
# Check if S3 is accessible
session = aioboto3.Session()
async with session.resource("s3",
aws_access_key_id=AWS_ACCESS_KEY_ID,
aws_secret_access_key=AWS_SECRET_ACCESS_KEY,
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

Loading…
Cancel
Save