refactor(proxy): move proxy logic to services.mitmproxy and update Docker service model
Build and Push to Registry / build (push) Successful in 29s
Build and Push to Registry / build (push) Successful in 29s
- Rename DockerService to DockerContainer and add folder attribute - Move proxy-related modules (models, validator) to services.mitmproxy - Update imports and references to new module locations - Refactor Docker utilities to use DockerContainer and improve service discovery - Add manager.py with create_proxy utility stub - Initialize discovered Docker services at app startup and warn if none found
This commit is contained in:
+15
@@ -1,4 +1,6 @@
|
||||
import sys
|
||||
from contextlib import asynccontextmanager
|
||||
from pathlib import Path
|
||||
|
||||
from fastapi import FastAPI
|
||||
|
||||
@@ -8,6 +10,7 @@ from core.config import settings
|
||||
from core.mongodb import close_mongodb, init_mongodb
|
||||
from core.redis import close_redis, init_redis
|
||||
from core.security import hash_password
|
||||
from integrations.docker import get_all_services
|
||||
from repositories.auth import ensure_auth_indexes, ensure_single_account
|
||||
from repositories.proxy import ensure_proxy_indexes
|
||||
|
||||
@@ -22,6 +25,18 @@ async def lifespan(_: FastAPI):
|
||||
password_hash=hash_password(settings.AUTH_PASSWORD),
|
||||
)
|
||||
await ensure_proxy_indexes()
|
||||
|
||||
home_dir = str(Path.home())
|
||||
app.state.services = get_all_services(home_dir) or []
|
||||
if not app.state.services:
|
||||
warning = (
|
||||
"\n" + "!" * 60 + "\n"
|
||||
" WARNING: No services found in home directory!\n"
|
||||
f" Scanned: {home_dir}\n"
|
||||
+ "!" * 60 + "\n"
|
||||
)
|
||||
print(warning, file=sys.stderr)
|
||||
|
||||
try:
|
||||
yield
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user