diff --git a/backend/Dockerfile b/backend/Dockerfile index 67006d98..da38204c 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -1,10 +1,12 @@ -FROM python:3.12-slim +FROM python:3.12-slim-bookworm WORKDIR /app # Oracle Instant Client runtime dependencies for thick mode. +# `libaio1` is available on Debian bookworm, while newer variants may expose `libaio1t64`. RUN apt-get update \ - && apt-get install -y --no-install-recommends libaio1 libnsl2 \ + && (apt-get install -y --no-install-recommends libaio1 libnsl2 \ + || apt-get install -y --no-install-recommends libaio1t64 libnsl2) \ && rm -rf /var/lib/apt/lists/* # Install Python dependencies diff --git a/backend/app/services/dify.py b/backend/app/services/dify.py index 4b4d0464..de2497fc 100644 --- a/backend/app/services/dify.py +++ b/backend/app/services/dify.py @@ -88,7 +88,7 @@ class DifyService: 'inputs': {}, 'query': query, 'response_mode': 'streaming', - 'conversation_id': conversation_id, + 'conversation_id': conversation_id or '', 'user': str(user_id), } @@ -115,6 +115,18 @@ class DifyService: response.status_code, response.reason, ) + if not response.ok and current_app: + try: + error_body = response.text[:2000] + except Exception: + error_body = "" + current_app.logger.error( + "[chat-stream] dify bad response status=%s url=%s payload=%s body=%s", + response.status_code, + url, + json.dumps(payload, ensure_ascii=False), + error_body, + ) response.raise_for_status() for line in response.iter_lines(): diff --git a/scripts/deploy.sh b/scripts/deploy.sh index c4ec7f73..3de32c21 100755 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -14,6 +14,21 @@ echo "=== 开始容器化部署流程 [$(date)] ===" # ------------------------------------------------------------------------------ PROJECT_DIR="/data/ai-platform/hxops" BRANCH="super" +ORACLE_CLIENT_DIR="${PROJECT_DIR}/oracle_client" + +check_oracle_client() { + if [ ! -d "$ORACLE_CLIENT_DIR" ]; then + echo "错误: 未找到 Oracle Instant Client 目录: $ORACLE_CLIENT_DIR" + echo "请先在项目根目录准备 oracle_client,并确保 docker-compose 能挂载到 /app/oracle_client。" + exit 1 + fi + + if ! find "$ORACLE_CLIENT_DIR" \( -iname "oci.dll" -o -iname "libclntsh.so" -o -iname "libclntsh.dylib" -o -type d -name "instantclient_*" \) | grep -q .; then + echo "错误: Oracle Instant Client 目录存在,但未发现可用客户端文件: $ORACLE_CLIENT_DIR" + echo "请确认目录中包含 Instant Client 解压内容,例如 instantclient_* / oci.dll / libclntsh.so。" + exit 1 + fi +} # 2. 更新代码 # ------------------------------------------------------------------------------ @@ -37,6 +52,9 @@ if ! command -v docker &> /dev/null; then exit 1 fi +echo ">>> [2.5/4] 检查 Oracle Instant Client..." +check_oracle_client + # 4. 构建与启动容器 # ------------------------------------------------------------------------------ echo ">>> [3/4] 重建并启动容器..." diff --git a/scripts/deploy_compose.sh b/scripts/deploy_compose.sh index baed6996..2cf4c0aa 100644 --- a/scripts/deploy_compose.sh +++ b/scripts/deploy_compose.sh @@ -19,6 +19,21 @@ DEPLOY_CONFIG_CHANGED="${6:-false}" ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" COMPOSE_FILE="${ROOT_DIR}/docker-compose.yml" ENV_FILE="${ROOT_DIR}/.env.${ENV_NAME}" +ORACLE_CLIENT_DIR="${ROOT_DIR}/oracle_client" + +check_oracle_client() { + if [[ ! -d "${ORACLE_CLIENT_DIR}" ]]; then + echo "Missing Oracle Instant Client directory: ${ORACLE_CLIENT_DIR}" + echo "Please prepare oracle_client under the project root so docker-compose can mount it to /app/oracle_client." + exit 1 + fi + + if ! find "${ORACLE_CLIENT_DIR}" \( -iname "oci.dll" -o -iname "libclntsh.so" -o -iname "libclntsh.dylib" -o -type d -name "instantclient_*" \) | grep -q .; then + echo "Oracle Instant Client directory exists but no client library was found: ${ORACLE_CLIENT_DIR}" + echo "Expected extracted Instant Client files such as instantclient_* / oci.dll / libclntsh.so." + exit 1 + fi +} # 基础文件检查:compose 文件必须存在 if [[ ! -f "${COMPOSE_FILE}" ]]; then @@ -91,6 +106,11 @@ echo "Deploying environment: ${ENV_NAME}" echo "Services: ${services[*]}" echo "Prebuilt image mode: ${PREBUILT_MODE}" +if printf '%s\n' "${services[@]}" | grep -qx "hxops-backend"; then + echo "Checking Oracle Instant Client directory..." + check_oracle_client +fi + # 预构建镜像模式:只启动,不构建 # 非预构建镜像模式:在目标机本地构建并启动 if [[ "${PREBUILT_MODE}" == "true" ]]; then