- Added pre-batch cleanup functionality to SerialBatchExecutor, allowing for cleanup tasks before processing items. - Introduced new task execution phases and improved error handling for task submissions. - Implemented inter-step delays and between-items delays for better task management. - Updated logging to capture detailed events during batch processing. - Enhanced configuration options for plugins in software_config.yaml to support new features. - Added tests for pre-batch cleanup and auto-close scenarios to ensure robust handling of edge cases. - Created a PowerShell script for automated callback handling from Revit.
82 lines
2.1 KiB
Python
82 lines
2.1 KiB
Python
"""FastAPI entrypoint."""
|
|
|
|
import logging
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.api.v1 import files, plugin_callbacks, websocket
|
|
from app.core.cad_batch_manager import cad_batch_manager
|
|
from app.core.log_manager import log_manager
|
|
from app.core.software_manager import software_manager
|
|
from app.core.websocket_manager import websocket_manager
|
|
|
|
|
|
|
|
|
|
def _configure_app_logging():
|
|
"""Ensure app.* logs are visible in console during runtime debugging."""
|
|
app_logger = logging.getLogger("app")
|
|
if app_logger.handlers:
|
|
return
|
|
|
|
handler = logging.StreamHandler()
|
|
formatter = logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s")
|
|
handler.setFormatter(formatter)
|
|
app_logger.addHandler(handler)
|
|
app_logger.setLevel(logging.INFO)
|
|
app_logger.propagate = False
|
|
|
|
|
|
_configure_app_logging()
|
|
app = FastAPI(
|
|
title="CadHubManage API",
|
|
description="Backend service for managing CAD software and batch processing tasks.",
|
|
version="1.1.0",
|
|
)
|
|
|
|
software_manager.set_websocket_manager(websocket_manager)
|
|
software_manager.set_log_manager(log_manager)
|
|
|
|
cad_batch_manager.set_websocket_manager(websocket_manager)
|
|
cad_batch_manager.set_log_manager(log_manager)
|
|
|
|
|
|
@app.on_event("startup")
|
|
async def startup_event():
|
|
await log_manager.start()
|
|
await cad_batch_manager.start()
|
|
|
|
|
|
@app.on_event("shutdown")
|
|
async def shutdown_event():
|
|
await cad_batch_manager.stop()
|
|
await log_manager.stop()
|
|
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(websocket.router, prefix="/api/v1/ws", tags=["WebSocket"])
|
|
app.include_router(files.router, prefix="/api/v1", tags=["Files"])
|
|
app.include_router(plugin_callbacks.router, prefix="/api/v1", tags=["PluginCallbacks"])
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"message": "CadHubManage API is running",
|
|
"version": "1.1.0",
|
|
"docs": "/docs",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health_check():
|
|
return {"status": "healthy"}
|