Add MongoDB check for /readyz
All checks were successful
continuous-integration/drone Build is passing

This commit is contained in:
Lauri Võsandi 2022-02-27 17:02:55 +02:00 committed by Lauri Võsandi
parent 2ab39f879d
commit 8fc9a3d065
2 changed files with 10 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import io
import json
import numpy as np
import os
import pymongo
import signal
import sys
from datetime import datetime, timedelta
@ -432,9 +433,14 @@ async def stream_wrapper(request):
@app.route("/readyz")
async def ready_check(request):
if app.ctx.mask is not None:
return response.text("OK")
return response.text("Not enough frames", status=503)
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")
@app.route("/event")

View File

@ -1,11 +1,4 @@
#!/bin/bash
mongo <<EOF
rs.initiate({
_id: 'rs0',
members: [
{_id: 0, host: '127.0.0.1:27017'}
]
})
rs.initiate()
EOF