fix(dev): improve gateway startup diagnostics for config errors (#1020)

This commit is contained in:
Willem Jiang
2026-03-08 21:06:57 +08:00
committed by GitHub
parent cf9af1fe75
commit 6b5c4fe6dd
4 changed files with 26 additions and 5 deletions

View File

@@ -170,6 +170,20 @@ dev:
@echo " → Frontend: Next.js"
@echo " → Nginx: Reverse Proxy"
@echo ""
@if ! { \
[ -n "$$DEER_FLOW_CONFIG_PATH" ] && [ -f "$$DEER_FLOW_CONFIG_PATH" ] || \
[ -f backend/config.yaml ] || \
[ -f config.yaml ]; \
}; then \
echo "✗ No DeerFlow config file found."; \
echo " Checked these locations:"; \
echo " - $$DEER_FLOW_CONFIG_PATH (when DEER_FLOW_CONFIG_PATH is set)"; \
echo " - backend/config.yaml"; \
echo " - ./config.yaml"; \
echo ""; \
echo " Run 'make config' from the repo root to generate ./config.yaml, then set required model API keys in .env or your config file."; \
exit 1; \
fi
@cleanup() { \
trap - INT TERM; \
echo ""; \
@@ -196,7 +210,10 @@ dev:
sleep 3; \
if ! lsof -i :8001 -sTCP:LISTEN -t >/dev/null 2>&1; then \
echo "✗ Gateway API failed to start. Last log output:"; \
tail -30 logs/gateway.log; \
tail -60 logs/gateway.log; \
echo ""; \
echo "Likely configuration errors:"; \
grep -E "Failed to load configuration|Environment variable .* not found|config\.yaml.*not found" logs/gateway.log | tail -5 || true; \
cleanup; \
fi; \
echo "✓ Gateway API started on localhost:8001"; \

View File

@@ -32,6 +32,7 @@ DeerFlow has newly integrated the intelligent search and crawling toolset indepe
- [🦌 DeerFlow - 2.0](#-deerflow---20)
- [Official Website](#official-website)
- [InfoQuest](#infoquest)
- [Table of Contents](#table-of-contents)
- [Quick Start](#quick-start)
- [Configuration](#configuration)
@@ -50,6 +51,7 @@ DeerFlow has newly integrated the intelligent search and crawling toolset indepe
- [Context Engineering](#context-engineering)
- [Long-Term Memory](#long-term-memory)
- [Recommended Models](#recommended-models)
- [Embedded Python Client](#embedded-python-client)
- [Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)
@@ -144,6 +146,8 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed Docker development guide.
If you prefer running services locally:
Prerequisite: complete the "Configuration" steps above first (`make config` and model API keys). `make dev` requires a valid configuration file (defaults to `config.yaml` in the project root; can be overridden via `DEER_FLOW_CONFIG_PATH`).
1. **Check prerequisites**:
```bash
make check # Verifies Node.js 22+, pnpm, uv, nginx

View File

@@ -74,7 +74,7 @@ When making code changes, you MUST update the relevant documentation:
```bash
make check # Check system requirements
make install # Install all dependencies (frontend + backend)
make dev # Start all services (LangGraph + Gateway + Frontend + Nginx)
make dev # Start all services (LangGraph + Gateway + Frontend + Nginx), with config.yaml preflight
make stop # Stop all services
```

View File

@@ -1,5 +1,4 @@
import logging
import sys
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
@@ -38,8 +37,9 @@ async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]:
get_app_config()
logger.info("Configuration loaded successfully")
except Exception as e:
logger.error(f"Failed to load configuration: {e}")
sys.exit(1)
error_msg = f"Failed to load configuration during gateway startup: {e}"
logger.exception(error_msg)
raise RuntimeError(error_msg) from e
config = get_gateway_config()
logger.info(f"Starting API Gateway on {config.host}:{config.port}")