Add some logging for healthchecks
	
		
			
	
		
	
	
		
	
		
			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:
		
							
								
								
									
										24
									
								
								camdetect.py
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								camdetect.py
									
									
									
									
									
								
							| @@ -500,25 +500,15 @@ async def stream_wrapper(request): | ||||
|  | ||||
| @app.route("/readyz") | ||||
| async def ready_check(request): | ||||
|     if app.ctx.mask is None: | ||||
|         return response.text("Not enough frames", status=503) | ||||
|     return response.text("OK") | ||||
|  | ||||
|  | ||||
| @app.route("/healthz") | ||||
| async def health_check(request): | ||||
|     if app.ctx.mask is None: | ||||
|         return response.text("Not enough frames", status=503) | ||||
|  | ||||
|     # Check if Mongo is accessible | ||||
|     logger.info("Testing if Mongo is accessible") | ||||
|     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) | ||||
|  | ||||
|     # Check if S3 is accessible | ||||
|     session = aioboto3.Session() | ||||
|     logger.info("Testing if S3 is writable") | ||||
|     async with session.resource("s3", | ||||
|                                 aws_access_key_id=AWS_ACCESS_KEY_ID, | ||||
|                                 aws_secret_access_key=AWS_SECRET_ACCESS_KEY, | ||||
| @@ -527,6 +517,16 @@ async def health_check(request): | ||||
|         await bucket.upload_fileobj(io.BytesIO(b"test"), "test") | ||||
|     return response.text("OK") | ||||
|  | ||||
|     print("Checking if there are any frames received") | ||||
|     if app.ctx.mask is None: | ||||
|         return response.text("Not enough frames", status=503) | ||||
|  | ||||
|  | ||||
| @app.route("/healthz") | ||||
| async def health_check(request): | ||||
|     if app.ctx.mask is None: | ||||
|         return response.text("Not enough frames", status=503) | ||||
|  | ||||
|  | ||||
| @app.route("/event") | ||||
| async def wrapper_stream_event(request): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user