Fix and UI imporvements
This commit is contained in:
@@ -40,6 +40,8 @@ class OrchestratorSettings(BaseServiceSettings):
|
||||
# Orchestration Settings
|
||||
ORCHESTRATION_ENABLED: bool = os.getenv("ORCHESTRATION_ENABLED", "true").lower() == "true"
|
||||
ORCHESTRATION_SCHEDULE: str = os.getenv("ORCHESTRATION_SCHEDULE", "30 5 * * *") # 5:30 AM daily (cron format)
|
||||
ORCHESTRATION_HOUR: int = int(os.getenv("ORCHESTRATION_HOUR", "2")) # Hour to run daily orchestration (default: 2 AM)
|
||||
ORCHESTRATION_MINUTE: int = int(os.getenv("ORCHESTRATION_MINUTE", "0")) # Minute to run (default: :00)
|
||||
ORCHESTRATION_TIMEOUT_SECONDS: int = int(os.getenv("ORCHESTRATION_TIMEOUT_SECONDS", "600")) # 10 minutes
|
||||
|
||||
# Tenant Processing
|
||||
|
||||
@@ -19,6 +19,7 @@ from datetime import datetime, date, timezone
|
||||
from decimal import Decimal
|
||||
from typing import List, Dict, Any, Optional
|
||||
import structlog
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
from apscheduler.triggers.cron import CronTrigger
|
||||
|
||||
# Updated imports - removed old alert system
|
||||
@@ -51,6 +52,9 @@ class OrchestratorSchedulerService:
|
||||
self.publisher = event_publisher
|
||||
self.config = config
|
||||
|
||||
# APScheduler instance for running daily orchestration
|
||||
self.scheduler = None
|
||||
|
||||
# Service clients
|
||||
self.forecast_client = ForecastServiceClient(config, "orchestrator-service")
|
||||
self.production_client = ProductionServiceClient(config, "orchestrator-service")
|
||||
@@ -670,13 +674,46 @@ class OrchestratorSchedulerService:
|
||||
|
||||
async def start(self):
|
||||
"""Start the orchestrator scheduler service"""
|
||||
logger.info("OrchestratorSchedulerService started")
|
||||
# Add any initialization logic here if needed
|
||||
if not settings.ORCHESTRATION_ENABLED:
|
||||
logger.info("Orchestration disabled via config")
|
||||
return
|
||||
|
||||
# Initialize APScheduler
|
||||
self.scheduler = AsyncIOScheduler()
|
||||
|
||||
# Add daily orchestration job
|
||||
self.scheduler.add_job(
|
||||
self.run_daily_orchestration,
|
||||
trigger=CronTrigger(
|
||||
hour=settings.ORCHESTRATION_HOUR,
|
||||
minute=settings.ORCHESTRATION_MINUTE
|
||||
),
|
||||
id='daily_orchestration',
|
||||
name='Daily Orchestration Workflow',
|
||||
replace_existing=True,
|
||||
max_instances=1,
|
||||
coalesce=True
|
||||
)
|
||||
|
||||
# Start the scheduler
|
||||
self.scheduler.start()
|
||||
|
||||
# Log next run time
|
||||
next_run = self.scheduler.get_job('daily_orchestration').next_run_time
|
||||
logger.info(
|
||||
"OrchestratorSchedulerService started with daily job",
|
||||
orchestration_hour=settings.ORCHESTRATION_HOUR,
|
||||
orchestration_minute=settings.ORCHESTRATION_MINUTE,
|
||||
next_run=next_run.isoformat() if next_run else None
|
||||
)
|
||||
|
||||
async def stop(self):
|
||||
"""Stop the orchestrator scheduler service"""
|
||||
logger.info("OrchestratorSchedulerService stopped")
|
||||
# Add any cleanup logic here if needed
|
||||
if self.scheduler and self.scheduler.running:
|
||||
self.scheduler.shutdown(wait=True)
|
||||
logger.info("OrchestratorSchedulerService stopped")
|
||||
else:
|
||||
logger.info("OrchestratorSchedulerService already stopped")
|
||||
|
||||
def get_circuit_breaker_stats(self) -> Dict[str, Any]:
|
||||
"""Get circuit breaker statistics for monitoring"""
|
||||
|
||||
Reference in New Issue
Block a user