feat(UI): added docker image and config
This commit is contained in:
@@ -28,6 +28,11 @@ logger = logging.getLogger(__name__)
|
||||
# Import authentication module
|
||||
from .auth import init_oauth_manager, get_oauth_manager
|
||||
|
||||
# Import scheduled tasks modules
|
||||
from .database import init_database
|
||||
from .scheduler import start_scheduler, stop_scheduler
|
||||
from .scheduled_tasks import router as scheduled_tasks_router
|
||||
|
||||
# Import BDFR API layer
|
||||
import sys
|
||||
import os
|
||||
@@ -72,6 +77,45 @@ except ImportError as e:
|
||||
|
||||
app = FastAPI(title="BDFR Web Interface", version="1.0.0")
|
||||
|
||||
# Application lifecycle events
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
"""Initialize services on application startup"""
|
||||
try:
|
||||
logger.info("Starting up BDFR Web Interface...")
|
||||
|
||||
# Initialize database
|
||||
init_database()
|
||||
logger.info("Database initialized")
|
||||
|
||||
# Start scheduler
|
||||
start_scheduler()
|
||||
logger.info("Scheduler started")
|
||||
|
||||
logger.info("Startup complete!")
|
||||
except Exception as e:
|
||||
logger.error(f"Startup error: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
@app.on_event("shutdown")
|
||||
async def shutdown_event():
|
||||
"""Cleanup on application shutdown"""
|
||||
try:
|
||||
logger.info("Shutting down BDFR Web Interface...")
|
||||
|
||||
# Stop scheduler
|
||||
stop_scheduler()
|
||||
logger.info("Scheduler stopped")
|
||||
|
||||
# Stop task queue
|
||||
from .task_queue import task_queue
|
||||
await task_queue.stop()
|
||||
logger.info("Task queue stopped")
|
||||
|
||||
logger.info("Shutdown complete!")
|
||||
except Exception as e:
|
||||
logger.error(f"Shutdown error: {e}", exc_info=True)
|
||||
|
||||
# Initialize OAuth2 manager
|
||||
def init_oauth():
|
||||
"""Initialize OAuth2 manager with credentials from environment or BDFR config"""
|
||||
@@ -131,6 +175,9 @@ os.makedirs(template_dir, exist_ok=True)
|
||||
app.mount("/static", StaticFiles(directory=static_dir), name="static")
|
||||
templates = Jinja2Templates(directory=template_dir)
|
||||
|
||||
# Include scheduled tasks router
|
||||
app.include_router(scheduled_tasks_router)
|
||||
|
||||
# WebSocket connection manager
|
||||
class ConnectionManager:
|
||||
def __init__(self):
|
||||
|
||||
Reference in New Issue
Block a user