Update Docker configuration, enhance error handling, and improve logging

- Added health check to the camera management API service in docker-compose.yml for better container reliability.
- Updated installation scripts in Dockerfile to check for existing dependencies before installation, improving efficiency.
- Enhanced error handling in the USDAVisionSystem class to allow partial operation if some components fail to start, preventing immediate shutdown.
- Improved logging throughout the application, including more detailed error messages and critical error handling in the main loop.
- Refactored WebSocketManager and CameraMonitor classes to use debug logging for connection events, reducing log noise.
This commit is contained in:
salirezav
2025-12-03 17:23:31 -05:00
parent 2bce817b4e
commit 933d4417a5
30 changed files with 4314 additions and 220 deletions

View File

@@ -44,12 +44,12 @@ class WebSocketManager:
async def connect(self, websocket: WebSocket):
await websocket.accept()
self.active_connections.append(websocket)
self.logger.info(f"WebSocket connected. Total connections: {len(self.active_connections)}")
self.logger.debug(f"WebSocket connected. Total connections: {len(self.active_connections)}")
def disconnect(self, websocket: WebSocket):
if websocket in self.active_connections:
self.active_connections.remove(websocket)
self.logger.info(f"WebSocket disconnected. Total connections: {len(self.active_connections)}")
self.logger.debug(f"WebSocket disconnected. Total connections: {len(self.active_connections)}")
async def send_personal_message(self, message: dict, websocket: WebSocket):
try:
@@ -300,9 +300,11 @@ class APIServer:
asyncio.set_event_loop(self._event_loop)
# Map our log level to uvicorn's log level
# Use "warning" for uvicorn to reduce noise (connection open/close messages)
# Application logs will still use the configured log level
uvicorn_log_level_map = {
"DEBUG": "debug",
"INFO": "info",
"DEBUG": "warning", # Suppress uvicorn DEBUG logs even if app is in DEBUG mode
"INFO": "warning", # Suppress uvicorn INFO logs (connection messages)
"WARNING": "warning",
"ERROR": "error",
"CRITICAL": "critical"