"백엔드_핵심_로직_구현_프론트엔드_연동_및_도커_배포_최적화_완료"
This commit is contained in:
@@ -9,14 +9,31 @@ from app.core.config import settings
|
||||
from app.db.init_db import init_db
|
||||
from app.workers.scheduler import start_scheduler
|
||||
|
||||
import logging
|
||||
|
||||
# Configure Logging
|
||||
logging.basicConfig(
|
||||
level=logging.INFO,
|
||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||
)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# Startup: Initialize DB
|
||||
logger.info("Initializing Database...")
|
||||
await init_db()
|
||||
|
||||
# Startup Sequence (Auth, Checks)
|
||||
await run_startup_sequence()
|
||||
|
||||
logger.info("Starting Background Scheduler...")
|
||||
start_scheduler()
|
||||
print("Database & Scheduler Initialized")
|
||||
|
||||
logger.info("Application Startup Complete.")
|
||||
yield
|
||||
# Shutdown: Cleanup if needed
|
||||
# Shutdown
|
||||
logger.info("Application Shutdown.")
|
||||
|
||||
app = FastAPI(
|
||||
title=settings.PROJECT_NAME,
|
||||
@@ -59,4 +76,4 @@ STATIC_DIR = BASE_DIR / "static"
|
||||
if STATIC_DIR.exists():
|
||||
app.mount("/", StaticFiles(directory=str(STATIC_DIR), html=True), name="static")
|
||||
else:
|
||||
print(f"Warning: Static directory not found at {STATIC_DIR}")
|
||||
logger.warning(f"Static directory not found at {STATIC_DIR}")
|
||||
|
||||
Reference in New Issue
Block a user