INNER CODE UNIT · Python

lifespan

caipe-io/ai-platform-engineering · ai_platform_engineering/autonomous_agents/src/autonomous_agents/main.py:59

async def lifespan(app: FastAPI):
    """Application lifespan handler."""
    settings = get_settings()
    logger.info("Starting Autonomous Agents service...")

    # Load webhook provider adapters (pointed at by WEBHOOK_PROVIDERS_FILE).
    try:
        load_adapters(settings.webhook_providers_file)
    except (FileNotFoundError, ValueError) as exc:
        fatal_exit(f"Failed to load webhook_providers.yaml: {exc}")

    # Ensure required MongoDB config is present before connecting
    if not settings.mongodb_uri or not settings.mongodb_database:
        fatal_exit(
            "MONGODB_URI and MONGODB_DATABASE must both be set. "
            f"(MONGODB_URI={'set' if settings.mongodb_uri else 'UNSET'}, "
            f"MONGODB_DATABASE={'set' if settings.mongodb_database else 'UNSET'}). "
            "Configure them in your .env / environment before restarting."

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…