demo seed change
This commit is contained in:
@@ -12,10 +12,13 @@ from sqlalchemy import text
|
||||
from app.core.config import settings
|
||||
from app.core.database import database_manager
|
||||
from app.services.production_alert_service import ProductionAlertService
|
||||
from app.services.production_scheduler import ProductionScheduler
|
||||
from app.services.production_notification_service import ProductionNotificationService
|
||||
from shared.service_base import StandardFastAPIService
|
||||
|
||||
# Import standardized routers
|
||||
from app.api import (
|
||||
internal_demo,
|
||||
production_batches,
|
||||
production_schedules,
|
||||
production_operations,
|
||||
@@ -23,7 +26,6 @@ from app.api import (
|
||||
analytics,
|
||||
quality_templates,
|
||||
equipment,
|
||||
internal_demo,
|
||||
orchestrator, # NEW: Orchestrator integration endpoint
|
||||
production_orders_operations, # Tenant deletion endpoints
|
||||
audit,
|
||||
@@ -65,6 +67,7 @@ class ProductionService(StandardFastAPIService):
|
||||
]
|
||||
|
||||
self.alert_service = None
|
||||
self.notification_service = None
|
||||
self.rabbitmq_client = None
|
||||
self.event_publisher = None
|
||||
# REMOVED: scheduler_service (replaced by Orchestrator Service)
|
||||
@@ -124,20 +127,28 @@ class ProductionService(StandardFastAPIService):
|
||||
await self.alert_service.start()
|
||||
self.logger.info("Production alert service started")
|
||||
|
||||
# Store services in app state
|
||||
app.state.alert_service = self.alert_service
|
||||
app.state.production_alert_service = self.alert_service # Also store with this name for internal trigger
|
||||
# Initialize notification service with EventPublisher
|
||||
self.notification_service = ProductionNotificationService(self.event_publisher)
|
||||
self.logger.info("Production notification service initialized")
|
||||
|
||||
# REMOVED: Production scheduler service initialization
|
||||
# Scheduling is now handled by the Orchestrator Service
|
||||
# which calls our /generate-schedule endpoint
|
||||
# Initialize production scheduler with alert service and database manager
|
||||
self.production_scheduler = ProductionScheduler(self.alert_service, self.database_manager)
|
||||
await self.production_scheduler.start()
|
||||
self.logger.info("Production scheduler started")
|
||||
|
||||
# Store services in app state
|
||||
app.state.alert_service = self.alert_service
|
||||
app.state.production_alert_service = self.alert_service # Also store with this name for internal trigger
|
||||
app.state.notification_service = self.notification_service # Notification service for state change events
|
||||
app.state.production_scheduler = self.production_scheduler # Store scheduler for manual triggering
|
||||
|
||||
async def on_shutdown(self, app: FastAPI):
|
||||
"""Custom shutdown logic for production service"""
|
||||
# Stop production scheduler
|
||||
if hasattr(self, 'production_scheduler') and self.production_scheduler:
|
||||
await self.production_scheduler.stop()
|
||||
self.logger.info("Production scheduler stopped")
|
||||
|
||||
# Stop alert service
|
||||
if self.alert_service:
|
||||
await self.alert_service.stop()
|
||||
@@ -203,8 +214,9 @@ service.add_router(production_schedules.router)
|
||||
service.add_router(production_operations.router)
|
||||
service.add_router(production_dashboard.router)
|
||||
service.add_router(analytics.router)
|
||||
service.add_router(internal_demo.router)
|
||||
service.add_router(internal_demo.router, tags=["internal-demo"])
|
||||
service.add_router(ml_insights.router) # ML insights endpoint
|
||||
service.add_router(ml_insights.internal_router) # Internal ML insights endpoint for demo cloning
|
||||
service.add_router(internal_alert_trigger_router) # Internal alert trigger for demo cloning
|
||||
|
||||
# REMOVED: test_production_scheduler endpoint
|
||||
@@ -218,4 +230,4 @@ if __name__ == "__main__":
|
||||
host="0.0.0.0",
|
||||
port=8000,
|
||||
reload=settings.DEBUG
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user