fix: session stability improvements
- Fix docker client initialization bug in app.py (context manager was closing client) - Add restart_session() method to preserve session IDs during container restarts - Add 60-second startup grace period before health checking new sessions - Fix _stop_container and _get_container_info to use docker_service API consistently - Disable mDNS in Dockerfile to prevent Bonjour service name conflicts - Remove old container before restart to free port bindings
This commit is contained in:
@@ -5,7 +5,6 @@ from fastapi import FastAPI
|
||||
|
||||
from config import USE_ASYNC_DOCKER, USE_DATABASE_STORAGE
|
||||
from session_manager import session_manager
|
||||
from async_docker_client import get_async_docker_client
|
||||
from http_pool import init_http_pool, shutdown_http_pool
|
||||
from database import init_database, shutdown_database, run_migrations
|
||||
from container_health import (
|
||||
@@ -43,12 +42,9 @@ async def lifespan(app: FastAPI):
|
||||
session_manager._load_sessions_from_file()
|
||||
|
||||
try:
|
||||
docker_client = None
|
||||
if USE_ASYNC_DOCKER:
|
||||
async with get_async_docker_client() as client:
|
||||
docker_client = client._docker if hasattr(client, "_docker") else None
|
||||
else:
|
||||
docker_client = session_manager.docker_service
|
||||
# Use the session manager's docker_service for health monitoring
|
||||
# This ensures the docker client stays alive for the lifetime of the application
|
||||
docker_client = session_manager.docker_service
|
||||
|
||||
await start_container_health_monitoring(session_manager, docker_client)
|
||||
logger.info("Container health monitoring started")
|
||||
|
||||
Reference in New Issue
Block a user