fix: 修复前后端启动问题,添加 BACKEND_PORT 配置
Some checks failed
构建并部署 AI Agent 服务 / deploy (push) Has been cancelled

This commit is contained in:
2026-04-22 01:34:34 +08:00
parent a869d884b7
commit d8da45bc97
12 changed files with 26 additions and 21 deletions

View File

@@ -76,6 +76,7 @@ ENABLE_GRAPH_TRACE=false
# -----------------------------------------------------------------------------
# 应用行为配置
# -----------------------------------------------------------------------------
BACKEND_PORT=8079
MEMORY_SUMMARIZE_INTERVAL=10
# -----------------------------------------------------------------------------

View File

@@ -46,6 +46,7 @@ ENV RAG_STORAGE_TYPE=postgres
# =============================================================================
# 应用行为配置
# =============================================================================
ENV BACKEND_PORT=8079
ENV MEMORY_SUMMARIZE_INTERVAL=10
ENV ENABLE_GRAPH_TRACE=false

View File

@@ -61,6 +61,7 @@ services:
# =========================================================================
# 应用行为配置
# =========================================================================
- BACKEND_PORT=8079
- MEMORY_SUMMARIZE_INTERVAL=${MEMORY_SUMMARIZE_INTERVAL:-10}
# =========================================================================

View File

@@ -3,7 +3,7 @@ AI Agent 前端模块
采用分层架构设计包含配置、状态、API客户端和UI组件
"""
from .logger import debug, info, warning, error
from logger import debug, info, warning, error
__version__ = "2.0.0"
__all__ = ["debug", "info", "warning", "error"]

View File

@@ -8,8 +8,8 @@ from typing import List, Dict, Any, Generator
import requests
# 使用相对导入
from .config import config
from .logger import error, warning
from config import config
from logger import error, warning
class APIClient:

View File

@@ -6,10 +6,9 @@
import re
import streamlit as st
# 使用相对导入
from ..state import AppState
from ..api_client import api_client
from ..config import config
from state import AppState
from api_client import api_client
from config import config
def render_chat_area():

View File

@@ -5,8 +5,7 @@
import streamlit as st
# 使用相对导入
from ..state import AppState
from state import AppState
def render_info_panel():

View File

@@ -6,9 +6,8 @@
import streamlit as st
from datetime import datetime
# 使用相对导入
from ..state import AppState
from ..api_client import api_client
from state import AppState
from api_client import api_client
def render_sidebar():
"""渲染左侧栏"""

View File

@@ -4,7 +4,7 @@
"""
import os
from .config import config
from config import config
import logging
from typing import Any
from dotenv import load_dotenv

View File

@@ -7,7 +7,7 @@ import uuid
from typing import List, Dict, Any
import streamlit as st
from .config import config
from config import config
class AppState:

View File

@@ -6,7 +6,8 @@ RAG Indexer 配置管理模块
"""
import os
from dotenv import load_dotenv
load_dotenv()
# ========== 辅助函数:类型转换 ==========
def _get_str(key: str) -> str | None:

View File

@@ -28,6 +28,11 @@ check_config() {
echo -e "${BLUE}📋 开始环境配置检查...${NC}"
echo ""
# 加载 .env 文件
set -a
source "$PROJECT_DIR/.env" 2>/dev/null || true
set +a
PASS=0
FAIL=0
WARN=0
@@ -286,7 +291,7 @@ start_embedding() {
# 启动 Python 服务
# =============================================================================
start_backend() {
echo -e "\n${BLUE}🚀 启动后端服务 (端口 8083)...${NC}"
echo -e "\n${BLUE}🚀 启动后端服务 (端口 8079)...${NC}"
cd "$PROJECT_DIR"
# 加载 .env 文件中的环境变量
@@ -294,9 +299,8 @@ start_backend() {
source .env 2>/dev/null || true
set +a
export PYTHONPATH="$PROJECT_DIR:$PROJECT_DIR/backend"
export BACKEND_PORT=8079
python backend/app/backend.py &
export PYTHONPATH="$PROJECT_DIR/backend"
python -m app.backend &
BACKEND_PID=$!
echo -e "${GREEN}✓ 后端服务已启动 (PID: $BACKEND_PID)${NC}"
sleep 2
@@ -311,8 +315,8 @@ start_frontend() {
source .env 2>/dev/null || true
set +a
export PYTHONPATH="$PROJECT_DIR:$PROJECT_DIR/backend"
streamlit run frontend/src/frontend_main.py &
export PYTHONPATH="$PROJECT_DIR/frontend/src"
streamlit run frontend/src/frontend_main.py --server.port 8501 --server.address 0.0.0.0 &
FRONTEND_PID=$!
echo -e "${GREEN}✓ 前端服务已启动 (PID: $FRONTEND_PID)${NC}"
echo -e "${GREEN}✓ 访问地址:${NC}"