Add readiness check for S3
This commit is contained in:
parent
3472e494f4
commit
3d1aa220dd
10
camdetect.py
10
camdetect.py
@ -483,6 +483,16 @@ async def stream_wrapper(request):
|
|||||||
|
|
||||||
@app.route("/readyz")
|
@app.route("/readyz")
|
||||||
async def ready_check(request):
|
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:
|
try:
|
||||||
async for i in app.ctx.coll.find().limit(1):
|
async for i in app.ctx.coll.find().limit(1):
|
||||||
break
|
break
|
||||||
|
Loading…
Reference in New Issue
Block a user