5349f21752
New FastAPI microservice (port 8020) providing unified blob storage via PUT/GET/DELETE/LIST HTTP API. Local filesystem backend is the default (zero extra deps). S3-compatible and WebDAV backends are built in. Backend is switchable at runtime via POST /migrate, which copies all objects to the new backend, verifies each one, atomically switches, then cleans up the old backend. WebDAV XML parsing uses defusedxml to prevent XXE attacks. Wired into docker-compose (storage_data volume) and registered in the backend service-health poller as 'storage-service'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
30 lines
771 B
Python
30 lines
771 B
Python
import logging
|
|
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
|
|
from app.core.config import settings
|
|
from app.routers import health, objects, migrate
|
|
from app.services.backend_manager import initialize_backend
|
|
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
|
|
)
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
initialize_backend()
|
|
logger.info("storage-service started (backend=%s)", settings.STORAGE_BACKEND)
|
|
yield
|
|
logger.info("storage-service shutting down")
|
|
|
|
|
|
app = FastAPI(title="Storage Service", lifespan=lifespan)
|
|
|
|
app.include_router(health.router)
|
|
app.include_router(objects.router)
|
|
app.include_router(migrate.router)
|