services
This commit is contained in:
13
app/main.py
13
app/main.py
@@ -3,7 +3,8 @@ from fastapi.middleware.cors import CORSMiddleware
|
||||
from contextlib import asynccontextmanager
|
||||
from app.config import settings
|
||||
from app.database import engine, Base
|
||||
from app.api import auth, vms, tunnel, admin, ssh_credentials
|
||||
from app.api import auth, vms, tunnel, admin, ssh_credentials, ws
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
# 로깅 설정
|
||||
@@ -47,9 +48,18 @@ async def lifespan(app: FastAPI):
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
# 백그라운드 모니터링 시작
|
||||
monitor_task = asyncio.create_task(ws.start_monitoring_task())
|
||||
|
||||
yield
|
||||
|
||||
# 종료 시
|
||||
monitor_task.cancel()
|
||||
try:
|
||||
await monitor_task
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
|
||||
logger.info("🛑 VConnect API 서버 종료")
|
||||
|
||||
# FastAPI 앱 생성
|
||||
@@ -75,6 +85,7 @@ app.include_router(vms.router, prefix=f"{settings.API_V1_PREFIX}/vms", tags=["VM
|
||||
app.include_router(tunnel.router, prefix=f"{settings.API_V1_PREFIX}/tunnel", tags=["터널 관리"])
|
||||
app.include_router(admin.router, prefix=f"{settings.API_V1_PREFIX}/admin", tags=["관리자"])
|
||||
app.include_router(ssh_credentials.router, prefix=f"{settings.API_V1_PREFIX}/ssh", tags=["SSH 자격증명"])
|
||||
app.include_router(ws.router, prefix="/ws", tags=["WebSocket"])
|
||||
|
||||
# Health Check
|
||||
@app.get("/health")
|
||||
|
||||
Reference in New Issue
Block a user