Add comprehensive documentation and final improvements
Documentation Added: - AI_INSIGHTS_DEMO_SETUP_GUIDE.md: Complete setup guide for demo sessions - AI_INSIGHTS_DATA_FLOW.md: Architecture and data flow diagrams - AI_INSIGHTS_QUICK_START.md: Quick reference guide - DEMO_SESSION_ANALYSIS_REPORT.md: Detailed analysis of demo session d67eaae4 - ROOT_CAUSE_ANALYSIS_AND_FIXES.md: Complete analysis of 8 issues (6 fixed, 2 analyzed) - COMPLETE_FIX_SUMMARY.md: Executive summary of all fixes - FIX_MISSING_INSIGHTS.md: Forecasting and procurement fix guide - FINAL_STATUS_SUMMARY.md: Status overview - verify_fixes.sh: Automated verification script - enhance_procurement_data.py: Procurement data enhancement script Service Improvements: - Demo session cleanup worker: Use proper settings for Redis configuration with TLS/auth - Procurement service: Add Redis initialization with proper error handling and cleanup - Production fixture: Remove duplicate worker assignments (cleaned 56 duplicates) - Orchestrator fixture: Add purchase order metadata for better tracking Impact: - Complete documentation for troubleshooting and setup - Improved Redis connection handling across services - Clean production data without duplicates - Better error handling and logging 🤖 Generated with Claude Code (https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -105,9 +105,23 @@ class ProcurementService(StandardFastAPIService):
|
||||
await self.delivery_tracking_service.start()
|
||||
self.logger.info("Delivery tracking service started")
|
||||
|
||||
# Initialize Redis for caching (optional - service can run without Redis)
|
||||
from shared.redis_utils import initialize_redis, get_redis_client
|
||||
try:
|
||||
redis_url = settings.REDIS_URL # Use configured Redis URL with TLS and auth
|
||||
await initialize_redis(redis_url, db=settings.REDIS_DB, max_connections=settings.REDIS_MAX_CONNECTIONS)
|
||||
redis_client = await get_redis_client()
|
||||
self.logger.info("Redis initialized successfully for procurement service",
|
||||
redis_url=redis_url.split("@")[-1], db=settings.REDIS_DB)
|
||||
except Exception as e:
|
||||
self.logger.warning("Failed to initialize Redis for caching, service will continue without caching",
|
||||
error=str(e), redis_url=redis_url.split("@")[-1] if 'redis_url' in locals() else "unknown")
|
||||
redis_client = None
|
||||
|
||||
# Store in app state for internal API access
|
||||
app.state.delivery_tracking_service = self.delivery_tracking_service
|
||||
app.state.event_publisher = self.event_publisher
|
||||
app.state.redis_client = redis_client
|
||||
|
||||
# Start overdue PO scheduler
|
||||
if self.rabbitmq_client and self.rabbitmq_client.connected:
|
||||
@@ -124,6 +138,14 @@ class ProcurementService(StandardFastAPIService):
|
||||
"""Custom shutdown logic for procurement service"""
|
||||
self.logger.info("Procurement Service shutting down...")
|
||||
|
||||
# Close Redis connections (if initialized)
|
||||
try:
|
||||
from shared.redis_utils import close_redis
|
||||
await close_redis()
|
||||
self.logger.info("Redis connections closed")
|
||||
except Exception as e:
|
||||
self.logger.debug("Redis cleanup failed or Redis was not initialized", error=str(e))
|
||||
|
||||
# Stop delivery tracking service
|
||||
if self.delivery_tracking_service:
|
||||
await self.delivery_tracking_service.stop()
|
||||
|
||||
Reference in New Issue
Block a user