auto-create sandbox dirs and switch to host socket compose

This commit is contained in:
Азамат Нураев 2026-05-05 10:03:00 +03:00
parent 06271db003
commit d4434a0afe
3 changed files with 15 additions and 34 deletions

View file

@ -1,5 +1,6 @@
import asyncio
from collections.abc import Awaitable, Callable
from pathlib import Path
from docker.errors import NotFound
from fastapi import FastAPI
@ -61,6 +62,12 @@ def _ensure_sandbox_network(container: AppContainer) -> None:
)
def _ensure_sandbox_dirs(container: AppContainer) -> None:
cfg = container.config.sandbox
for path_str in (cfg.dependencies_host_path, cfg.lambda_tools_host_path):
Path(path_str).mkdir(parents=True, exist_ok=True)
def _build_startup_handler(
app: FastAPI,
container: AppContainer,
@ -71,6 +78,7 @@ def _build_startup_handler(
return
await asyncio.to_thread(_ensure_sandbox_network, container)
await asyncio.to_thread(_ensure_sandbox_dirs, container)
await asyncio.to_thread(container.sandbox_reconciler.execute)
stop_event = asyncio.Event()