30 lines
789 B
Python
30 lines
789 B
Python
# coding=utf-8
|
|
"""
|
|
@Time :2026/6/24
|
|
@Author :tao.chen
|
|
"""
|
|
from contextlib import asynccontextmanager
|
|
from fastapi import FastAPI
|
|
from spark_executor import app as spark_executor_app
|
|
from common.factory import init_mcp_server
|
|
from common.logging import logger
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: "FastAPI"):
|
|
logger.info(f"Startup {app.title}")
|
|
spark_executor_mcp = init_mcp_server(spark_executor_app)
|
|
spark_executor_mcp.mount_http(app, mount_path="/spark-executor-mcp")
|
|
logger.info(f"include {spark_executor_app.title}, version {spark_executor_app.version}")
|
|
yield
|
|
logger.info(f"Shutdown {app.title}")
|
|
|
|
app = FastAPI(title="Main App", lifespan=lifespan)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
import uvicorn
|
|
|
|
uvicorn.run(app, host="0.0.0.0", port=8000)
|
|
|