Add MongoDB check for /readyz
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
2ab39f879d
commit
8fc9a3d065
10
camdetect.py
10
camdetect.py
@ -8,6 +8,7 @@ import io
|
|||||||
import json
|
import json
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
|
import pymongo
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
@ -432,9 +433,14 @@ 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 not None:
|
try:
|
||||||
return response.text("OK")
|
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("Not enough frames", status=503)
|
||||||
|
return response.text("OK")
|
||||||
|
|
||||||
|
|
||||||
@app.route("/event")
|
@app.route("/event")
|
||||||
|
@ -1,11 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
mongo <<EOF
|
mongo <<EOF
|
||||||
|
rs.initiate()
|
||||||
rs.initiate({
|
|
||||||
_id: 'rs0',
|
|
||||||
members: [
|
|
||||||
{_id: 0, host: '127.0.0.1:27017'}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user