fix: correct entrypoint script trap and uvicorn execution

- Move trap setup before uvicorn (was after, never executed)
- Use exec to replace bash with uvicorn process (better signal handling)
- Ensures uvicorn stays running as PID 1 in container
This commit is contained in:
2025-10-31 14:00:57 -04:00
parent cfa2428393
commit ceb2eabff9

View File

@@ -47,19 +47,19 @@ cd /app
python agent_tools/start_mcp_services.py & python agent_tools/start_mcp_services.py &
MCP_PID=$! MCP_PID=$!
# Setup cleanup trap before starting uvicorn
trap "echo '🛑 Stopping services...'; kill $MCP_PID 2>/dev/null; exit 0" EXIT SIGTERM SIGINT
# Step 3: Wait for services to initialize # Step 3: Wait for services to initialize
echo "⏳ Waiting for MCP services to start..." echo "⏳ Waiting for MCP services to start..."
sleep 3 sleep 3
# Step 4: Start FastAPI server with uvicorn # Step 4: Start FastAPI server with uvicorn (this blocks)
# Note: Container always uses port 8080 internally # Note: Container always uses port 8080 internally
# The API_PORT env var only affects the host port mapping in docker-compose.yml # The API_PORT env var only affects the host port mapping in docker-compose.yml
echo "🌐 Starting FastAPI server on port 8080..." echo "🌐 Starting FastAPI server on port 8080..."
uvicorn api.main:app \ exec uvicorn api.main:app \
--host 0.0.0.0 \ --host 0.0.0.0 \
--port 8080 \ --port 8080 \
--log-level info \ --log-level info \
--access-log --access-log
# Cleanup on exit
trap "echo '🛑 Stopping services...'; kill $MCP_PID 2>/dev/null; exit 0" EXIT SIGTERM SIGINT