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:
		
							
								
								
									
										10
									
								
								camdetect.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								camdetect.py
									
									
									
									
									
								
							| @@ -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") | ||||
|     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") | ||||
|   | ||||
| @@ -1,11 +1,4 @@ | ||||
| #!/bin/bash | ||||
| mongo <<EOF | ||||
|  | ||||
| rs.initiate({ | ||||
|     _id: 'rs0', | ||||
|     members: [ | ||||
|         {_id: 0, host: '127.0.0.1:27017'} | ||||
|     ] | ||||
| }) | ||||
|  | ||||
| rs.initiate() | ||||
| EOF | ||||
|   | ||||
		Reference in New Issue
	
	Block a user