mirror of
https://github.com/camel-ai/owl.git
synced 2025-12-26 10:07:51 +08:00
修复 | 语法错误,中文乱码 (#156)
This commit is contained in:
commit
ab5f1e3c0d
@ -1,14 +1,18 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
echo 在Windows上构建Docker镜像... | Building Docker image on Windows...
|
||||
echo 在Windows上构建Docker镜像...
|
||||
echo Building Docker image on Windows...
|
||||
|
||||
REM 设置配置变量 | Set configuration variables
|
||||
REM 设置配置变量
|
||||
REM Set configuration variables
|
||||
set CACHE_DIR=.docker-cache\pip
|
||||
set BUILD_ARGS=--build-arg BUILDKIT_INLINE_CACHE=1
|
||||
set COMPOSE_FILE=docker-compose.yml
|
||||
|
||||
REM 解析命令行参数 | Parse command line arguments
|
||||
REM 解析命令行参数
|
||||
REM Parse command line arguments
|
||||
set CLEAN_CACHE=0
|
||||
set REBUILD=0
|
||||
set SERVICE=
|
||||
@ -32,80 +36,106 @@ if /i "%~1"=="--service" (
|
||||
goto :parse_args
|
||||
)
|
||||
if /i "%~1"=="--help" (
|
||||
echo 用法 | Usage: build_docker.bat [选项 | options]
|
||||
echo 选项 | Options:
|
||||
echo --clean 清理缓存目录 | Clean cache directory
|
||||
echo --rebuild 强制重新构建镜像 | Force rebuild image
|
||||
echo --service 指定要构建的服务名称 | Specify service name to build
|
||||
echo --help 显示此帮助信息 | Show this help message
|
||||
echo 用法: build_docker.bat [选项]
|
||||
echo Usage: build_docker.bat [options]
|
||||
echo 选项:
|
||||
echo Options:
|
||||
echo --clean 清理缓存目录
|
||||
echo --clean Clean cache directory
|
||||
echo --rebuild 强制重新构建镜像
|
||||
echo --rebuild Force rebuild image
|
||||
echo --service 指定要构建的服务名称
|
||||
echo --service Specify service name to build
|
||||
echo --help 显示此帮助信息
|
||||
echo --help Show this help message
|
||||
exit /b 0
|
||||
)
|
||||
shift
|
||||
goto :parse_args
|
||||
:end_parse_args
|
||||
|
||||
REM 检查Docker是否安装 | Check if Docker is installed
|
||||
REM 检查Docker是否安装
|
||||
REM Check if Docker is installed
|
||||
where docker >nul 2>nul
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo 错误 | Error: Docker未安装 | Docker not installed
|
||||
echo 请先安装Docker Desktop | Please install Docker Desktop first: https://docs.docker.com/desktop/install/windows-install/
|
||||
echo 错误: Docker未安装
|
||||
echo Error: Docker not installed
|
||||
echo 请先安装Docker Desktop
|
||||
echo Please install Docker Desktop first: https://docs.docker.com/desktop/install/windows-install/
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查Docker是否运行 | Check if Docker is running
|
||||
REM 检查Docker是否运行
|
||||
REM Check if Docker is running
|
||||
docker info >nul 2>nul
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo 错误 | Error: Docker未运行 | Docker not running
|
||||
echo 请启动Docker Desktop应用程序 | Please start Docker Desktop application
|
||||
echo 错误: Docker未运行
|
||||
echo Error: Docker not running
|
||||
echo 请启动Docker Desktop应用程序
|
||||
echo Please start Docker Desktop application
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查docker-compose.yml文件是否存在 | Check if docker-compose.yml file exists
|
||||
REM 检查docker-compose.yml文件是否存在
|
||||
REM Check if docker-compose.yml file exists
|
||||
if not exist "%COMPOSE_FILE%" (
|
||||
echo 错误 | Error: 未找到%COMPOSE_FILE%文件 | %COMPOSE_FILE% file not found
|
||||
echo 请确保在正确的目录中运行此脚本 | Please make sure you are running this script in the correct directory
|
||||
echo 错误: 未找到%COMPOSE_FILE%文件
|
||||
echo Error: %COMPOSE_FILE% file not found
|
||||
echo 请确保在正确的目录中运行此脚本
|
||||
echo Please make sure you are running this script in the correct directory
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 检查Docker Compose命令 | Check Docker Compose command
|
||||
REM 检查Docker Compose命令
|
||||
REM Check Docker Compose command
|
||||
where docker-compose >nul 2>nul
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
set COMPOSE_CMD=docker-compose
|
||||
) else (
|
||||
echo 尝试使用新的docker compose命令... | Trying to use new docker compose command...
|
||||
echo 尝试使用新的docker compose命令...
|
||||
echo Trying to use new docker compose command...
|
||||
docker compose version >nul 2>nul
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
set COMPOSE_CMD=docker compose
|
||||
) else (
|
||||
echo 错误 | Error: 未找到Docker Compose命令 | Docker Compose command not found
|
||||
echo 请确保Docker Desktop已正确安装 | Please make sure Docker Desktop is properly installed
|
||||
echo 错误: 未找到Docker Compose命令
|
||||
echo Error: Docker Compose command not found
|
||||
echo 请确保Docker Desktop已正确安装
|
||||
echo Please make sure Docker Desktop is properly installed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM 设置Docker BuildKit环境变量 | Set Docker BuildKit environment variables
|
||||
REM 设置Docker BuildKit环境变量
|
||||
REM Set Docker BuildKit environment variables
|
||||
set DOCKER_BUILDKIT=1
|
||||
set COMPOSE_DOCKER_CLI_BUILD=1
|
||||
|
||||
echo 启用Docker BuildKit加速构建... | Enabling Docker BuildKit to accelerate build...
|
||||
echo 启用Docker BuildKit加速构建...
|
||||
echo Enabling Docker BuildKit to accelerate build...
|
||||
|
||||
REM 清理缓存(如果指定) | Clean cache (if specified)
|
||||
REM 清理缓存(如果指定)
|
||||
REM Clean cache (if specified)
|
||||
if %CLEAN_CACHE% EQU 1 (
|
||||
echo 清理缓存目录... | Cleaning cache directory...
|
||||
echo 清理缓存目录...
|
||||
echo Cleaning cache directory...
|
||||
if exist "%CACHE_DIR%" rmdir /s /q "%CACHE_DIR%"
|
||||
)
|
||||
|
||||
REM 创建缓存目录 | Create cache directory
|
||||
REM 创建缓存目录
|
||||
REM Create cache directory
|
||||
if not exist "%CACHE_DIR%" (
|
||||
echo 创建缓存目录... | Creating cache directory...
|
||||
echo 创建缓存目录...
|
||||
echo Creating cache directory...
|
||||
mkdir "%CACHE_DIR%"
|
||||
)
|
||||
|
||||
REM 添加构建时间标记 | Add build time tag
|
||||
REM 添加构建时间标记
|
||||
REM Add build time tag
|
||||
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
|
||||
set "YEAR=%dt:~0,4%"
|
||||
set "MONTH=%dt:~4,2%"
|
||||
@ -115,33 +145,42 @@ set "MINUTE=%dt:~10,2%"
|
||||
set "BUILD_TIME=%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%"
|
||||
set "BUILD_ARGS=%BUILD_ARGS% --build-arg BUILD_TIME=%BUILD_TIME%"
|
||||
|
||||
REM 构建Docker镜像 | Build Docker image
|
||||
echo 开始构建Docker镜像... | Starting to build Docker image...
|
||||
REM 构建Docker镜像
|
||||
REM Build Docker image
|
||||
echo 开始构建Docker镜像...
|
||||
echo Starting to build Docker image...
|
||||
|
||||
if "%SERVICE%"=="" (
|
||||
if %REBUILD% EQU 1 (
|
||||
echo 强制重新构建所有服务... | Force rebuilding all services...
|
||||
echo 强制重新构建所有服务...
|
||||
echo Force rebuilding all services...
|
||||
%COMPOSE_CMD% build --no-cache %BUILD_ARGS%
|
||||
) else (
|
||||
%COMPOSE_CMD% build %BUILD_ARGS%
|
||||
)
|
||||
) else (
|
||||
if %REBUILD% EQU 1 (
|
||||
echo 强制重新构建服务 %SERVICE%... | Force rebuilding service %SERVICE%...
|
||||
echo 强制重新构建服务 %SERVICE%...
|
||||
echo Force rebuilding service %SERVICE%...
|
||||
%COMPOSE_CMD% build --no-cache %BUILD_ARGS% %SERVICE%
|
||||
) else (
|
||||
echo 构建服务 %SERVICE%... | Building service %SERVICE%...
|
||||
echo 构建服务 %SERVICE%...
|
||||
echo Building service %SERVICE%...
|
||||
%COMPOSE_CMD% build %BUILD_ARGS% %SERVICE%
|
||||
)
|
||||
)
|
||||
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo Docker镜像构建成功! | Docker image build successful!
|
||||
echo 构建时间 | Build time: %BUILD_TIME%
|
||||
echo 可以使用以下命令启动容器: | You can use the following command to start the container:
|
||||
echo Docker镜像构建成功!
|
||||
echo Docker image build successful!
|
||||
echo 构建时间: %BUILD_TIME%
|
||||
echo Build time: %BUILD_TIME%
|
||||
echo 可以使用以下命令启动容器:
|
||||
echo You can use the following command to start the container:
|
||||
echo %COMPOSE_CMD% up -d
|
||||
) else (
|
||||
echo Docker镜像构建失败,请检查错误信息。 | Docker image build failed, please check error messages.
|
||||
echo Docker镜像构建失败,请检查错误信息。
|
||||
echo Docker image build failed, please check error messages.
|
||||
)
|
||||
|
||||
pause
|
||||
@ -1,62 +1,88 @@
|
||||
@echo off
|
||||
echo 检查Docker环境... | Checking Docker environment...
|
||||
chcp 65001 >nul
|
||||
echo 检查Docker环境...
|
||||
echo Checking Docker environment...
|
||||
|
||||
REM 检查Docker是否安装 | Check if Docker is installed
|
||||
REM 检查Docker是否安装
|
||||
REM Check if Docker is installed
|
||||
where docker >nul 2>nul
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo 错误 | Error: Docker未安装 | Docker not installed
|
||||
echo 在Windows上安装Docker的方法 | How to install Docker on Windows:
|
||||
echo 1. 访问 | Visit https://docs.docker.com/desktop/install/windows-install/ 下载Docker Desktop | to download Docker Desktop
|
||||
echo 2. 安装并启动Docker Desktop | Install and start Docker Desktop
|
||||
echo 错误: Docker未安装
|
||||
echo Error: Docker not installed
|
||||
echo 在Windows上安装Docker的方法:
|
||||
echo How to install Docker on Windows:
|
||||
echo 1. 访问 https://docs.docker.com/desktop/install/windows-install/ 下载Docker Desktop
|
||||
echo 1. Visit https://docs.docker.com/desktop/install/windows-install/ to download Docker Desktop
|
||||
echo 2. 安装并启动Docker Desktop
|
||||
echo 2. Install and start Docker Desktop
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Docker已安装 | Docker is installed
|
||||
echo Docker已安装
|
||||
echo Docker is installed
|
||||
|
||||
REM 检查Docker Compose是否安装 | Check if Docker Compose is installed
|
||||
REM 检查Docker Compose是否安装
|
||||
REM Check if Docker Compose is installed
|
||||
where docker-compose >nul 2>nul
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo 警告 | Warning: Docker-Compose未找到,尝试使用新的docker compose命令 | Docker-Compose not found, trying to use new docker compose command
|
||||
echo 警告: Docker-Compose未找到,尝试使用新的docker compose命令
|
||||
echo Warning: Docker-Compose not found, trying to use new docker compose command
|
||||
docker compose version >nul 2>nul
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo 错误 | Error: Docker Compose未安装 | Docker Compose not installed
|
||||
echo Docker Desktop for Windows应该已包含Docker Compose | Docker Desktop for Windows should already include Docker Compose
|
||||
echo 请确保Docker Desktop已正确安装 | Please make sure Docker Desktop is properly installed
|
||||
echo 错误: Docker Compose未安装
|
||||
echo Error: Docker Compose not installed
|
||||
echo Docker Desktop for Windows应该已包含Docker Compose
|
||||
echo Docker Desktop for Windows should already include Docker Compose
|
||||
echo 请确保Docker Desktop已正确安装
|
||||
echo Please make sure Docker Desktop is properly installed
|
||||
pause
|
||||
exit /b 1
|
||||
) else (
|
||||
echo 使用新的docker compose命令 | Using new docker compose command
|
||||
echo 使用新的docker compose命令
|
||||
echo Using new docker compose command
|
||||
set COMPOSE_CMD=docker compose
|
||||
)
|
||||
) else (
|
||||
echo Docker-Compose已安装 | Docker-Compose is installed
|
||||
echo Docker-Compose已安装
|
||||
echo Docker-Compose is installed
|
||||
set COMPOSE_CMD=docker-compose
|
||||
)
|
||||
|
||||
REM 检查Docker是否正在运行 | Check if Docker is running
|
||||
REM 检查Docker是否正在运行
|
||||
REM Check if Docker is running
|
||||
docker info >nul 2>nul
|
||||
if %ERRORLEVEL% NEQ 0 (
|
||||
echo 错误 | Error: Docker未运行 | Docker not running
|
||||
echo 请启动Docker Desktop应用程序 | Please start Docker Desktop application
|
||||
echo 错误: Docker未运行
|
||||
echo Error: Docker not running
|
||||
echo 请启动Docker Desktop应用程序
|
||||
echo Please start Docker Desktop application
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo Docker正在运行 | Docker is running
|
||||
echo Docker正在运行
|
||||
echo Docker is running
|
||||
|
||||
REM 检查是否有.env文件 | Check if .env file exists
|
||||
if not exist "owl\.env" (
|
||||
echo 警告 | Warning: 未找到owl\.env文件 | owl\.env file not found
|
||||
echo 请运行以下命令创建环境变量文件 | Please run the following command to create environment variable file:
|
||||
echo copy owl\.env_template owl\.env
|
||||
echo 然后编辑owl\.env文件,填写必要的API密钥 | Then edit owl\.env file and fill in necessary API keys
|
||||
REM 检查是否有.env文件
|
||||
REM Check if .env file exists
|
||||
if not exist "..\owl\.env" (
|
||||
echo 警告: 未找到owl\.env文件
|
||||
echo Warning: owl\.env file not found
|
||||
echo 请运行以下命令创建环境变量文件
|
||||
echo Please run the following command to create environment variable file:
|
||||
echo copy ..\owl\.env_template ..\owl\.env
|
||||
echo 然后编辑owl\.env文件,填写必要的API密钥
|
||||
echo Then edit owl\.env file and fill in necessary API keys
|
||||
) else (
|
||||
echo 环境变量文件已存在 | Environment variable file exists
|
||||
echo 环境变量文件已存在
|
||||
echo Environment variable file exists
|
||||
)
|
||||
|
||||
echo 所有检查完成,您的系统已准备好构建和运行OWL项目的Docker容器 | All checks completed, your system is ready to build and run OWL project Docker container
|
||||
echo 请运行以下命令构建Docker镜像 | Please run the following command to build Docker image:
|
||||
echo 所有检查完成,您的系统已准备好构建和运行OWL项目的Docker容器
|
||||
echo All checks completed, your system is ready to build and run OWL project Docker container
|
||||
echo 请运行以下命令构建Docker镜像:
|
||||
echo Please run the following command to build Docker image:
|
||||
echo %COMPOSE_CMD% build
|
||||
|
||||
pause
|
||||
@ -1,116 +1,178 @@
|
||||
@echo off
|
||||
chcp 65001 >nul
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
REM 定义配置变量 | Define configuration variables
|
||||
REM 定义配置变量
|
||||
REM Define configuration variables
|
||||
set SERVICE_NAME=owl
|
||||
set PYTHON_CMD=xvfb-python
|
||||
set MAX_WAIT_SECONDS=60
|
||||
set CHECK_INTERVAL_SECONDS=2
|
||||
|
||||
REM 检查参数 | Check parameters
|
||||
REM 检查参数
|
||||
REM Check parameters
|
||||
if "%~1"=="" (
|
||||
echo 用法 | Usage: run_in_docker.bat [脚本名称 | script name] "你的问题 | your question"
|
||||
echo 例如 | Example: run_in_docker.bat run.py "什么是人工智能? | What is artificial intelligence?"
|
||||
echo 或者 | Or: run_in_docker.bat run_deepseek_example.py "什么是人工智能? | What is artificial intelligence?"
|
||||
echo 如果不指定脚本名称,默认使用 run.py | If script name is not specified, run.py will be used by default
|
||||
echo 用法: run_in_docker.bat [脚本名称] "你的问题"
|
||||
echo Usage: run_in_docker.bat [script name] "your question"
|
||||
echo 例如: run_in_docker.bat run.py "什么是人工智能?"
|
||||
echo Example: run_in_docker.bat run.py "What is artificial intelligence?"
|
||||
echo 或者: run_in_docker.bat run_deepseek_example.py "什么是人工智能?"
|
||||
echo Or: run_in_docker.bat run_deepseek_example.py "What is artificial intelligence?"
|
||||
echo 如果不指定脚本名称,默认使用 run.py
|
||||
echo If script name is not specified, run.py will be used by default
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
REM 判断第一个参数是否是脚本名称 | Determine if the first parameter is a script name
|
||||
REM 判断第一个参数是否是脚本名称
|
||||
REM Determine if the first parameter is a script name
|
||||
set SCRIPT_NAME=%~1
|
||||
set QUERY=%~2
|
||||
|
||||
if "!SCRIPT_NAME:~-3!"==".py" (
|
||||
REM 如果提供了第二个参数,则为查询内容 | If a second parameter is provided, it's the query content
|
||||
REM 如果提供了第二个参数,则为查询内容
|
||||
REM If a second parameter is provided, it's the query content
|
||||
if "!QUERY!"=="" (
|
||||
echo 请提供查询参数,例如 | Please provide query parameter, e.g.: run_in_docker.bat !SCRIPT_NAME! "你的问题 | your question"
|
||||
echo 请提供查询参数,例如: run_in_docker.bat !SCRIPT_NAME! "你的问题"
|
||||
echo Please provide query parameter, e.g.: run_in_docker.bat !SCRIPT_NAME! "your question"
|
||||
exit /b 1
|
||||
)
|
||||
) else (
|
||||
REM 如果第一个参数不是脚本名称,则默认使用 run.py | If the first parameter is not a script name, use run.py by default
|
||||
REM 如果第一个参数不是脚本名称,则默认使用 run.py
|
||||
REM If the first parameter is not a script name, use run.py by default
|
||||
set QUERY=!SCRIPT_NAME!
|
||||
set SCRIPT_NAME=run.py
|
||||
)
|
||||
|
||||
REM 检查脚本是否存在 | Check if the script exists
|
||||
if not exist "owl\!SCRIPT_NAME!" (
|
||||
echo 错误 | Error: 脚本 | Script 'owl\!SCRIPT_NAME!' 不存在 | does not exist
|
||||
echo 可用的脚本有 | Available scripts:
|
||||
dir /b owl\*.py | findstr /v "__"
|
||||
REM 检查脚本是否存在
|
||||
REM Check if the script exists
|
||||
if not exist "..\owl\!SCRIPT_NAME!" (
|
||||
echo 错误: 脚本 '..\owl\!SCRIPT_NAME!' 不存在
|
||||
echo Error: Script '..\owl\!SCRIPT_NAME!' does not exist
|
||||
echo 可用的脚本有:
|
||||
echo Available scripts:
|
||||
dir /b ..\owl\*.py | findstr /v "__"
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
echo 使用脚本 | Using script: !SCRIPT_NAME!
|
||||
echo 查询内容 | Query content: !QUERY!
|
||||
echo 使用脚本: !SCRIPT_NAME!
|
||||
echo Using script: !SCRIPT_NAME!
|
||||
echo 查询内容: !QUERY!
|
||||
echo Query content: !QUERY!
|
||||
|
||||
REM 从docker-compose.yml获取服务名称(如果文件存在) | Get service name from docker-compose.yml (if file exists)
|
||||
if exist ".container\docker-compose.yml" (
|
||||
for /f "tokens=*" %%a in ('findstr /r "^ [a-zA-Z0-9_-]*:" .container\docker-compose.yml') do (
|
||||
REM 优先检查新版 docker compose 命令
|
||||
REM Check new docker compose command first
|
||||
docker compose version >nul 2>nul
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo 使用新版 docker compose 命令
|
||||
echo Using new docker compose command
|
||||
set COMPOSE_CMD=docker compose
|
||||
) else (
|
||||
REM 如果新版不可用,检查旧版 docker-compose
|
||||
REM If new version is not available, check old docker-compose
|
||||
where docker-compose >nul 2>nul
|
||||
if %ERRORLEVEL% EQU 0 (
|
||||
echo 使用旧版 docker-compose 命令
|
||||
echo Using old docker-compose command
|
||||
set COMPOSE_CMD=docker-compose
|
||||
) else (
|
||||
echo 错误: Docker Compose 未安装
|
||||
echo Error: Docker Compose not installed
|
||||
echo 请确保 Docker Desktop 已正确安装
|
||||
echo Please make sure Docker Desktop is properly installed
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM 从docker-compose.yml获取服务名称(如果文件存在)
|
||||
REM Get service name from docker-compose.yml (if file exists)
|
||||
if exist "docker-compose.yml" (
|
||||
for /f "tokens=*" %%a in ('findstr /r "^ [a-zA-Z0-9_-]*:" docker-compose.yml') do (
|
||||
set line=%%a
|
||||
set service=!line:~2,-1!
|
||||
if not "!service!"=="" (
|
||||
REM 使用第一个找到的服务名称 | Use the first service name found
|
||||
REM 使用第一个找到的服务名称
|
||||
REM Use the first service name found
|
||||
set SERVICE_NAME=!service!
|
||||
echo 从docker-compose.yml检测到服务名称 | Detected service name from docker-compose.yml: !SERVICE_NAME!
|
||||
echo 从docker-compose.yml检测到服务名称: !SERVICE_NAME!
|
||||
echo Detected service name from docker-compose.yml: !SERVICE_NAME!
|
||||
goto :found_service
|
||||
)
|
||||
)
|
||||
)
|
||||
:found_service
|
||||
|
||||
REM 确保Docker容器正在运行 | Ensure Docker container is running
|
||||
docker-compose ps | findstr "!SERVICE_NAME!.*Up" > nul
|
||||
REM 确保Docker容器正在运行
|
||||
REM Ensure Docker container is running
|
||||
%COMPOSE_CMD% ps | findstr "!SERVICE_NAME!.*Up" > nul
|
||||
if errorlevel 1 (
|
||||
echo 启动Docker容器... | Starting Docker container...
|
||||
docker-compose up -d
|
||||
echo 启动Docker容器...
|
||||
echo Starting Docker container...
|
||||
%COMPOSE_CMD% up -d
|
||||
|
||||
REM 使用循环检查容器是否就绪 | Use loop to check if container is ready
|
||||
echo 等待容器启动... | Waiting for container to start...
|
||||
REM 使用循环检查容器是否就绪
|
||||
REM Use loop to check if container is ready
|
||||
echo 等待容器启动...
|
||||
echo Waiting for container to start...
|
||||
set /a total_wait=0
|
||||
|
||||
:wait_loop
|
||||
timeout /t !CHECK_INTERVAL_SECONDS! /nobreak > nul
|
||||
set /a total_wait+=!CHECK_INTERVAL_SECONDS!
|
||||
|
||||
docker-compose ps | findstr "!SERVICE_NAME!.*Up" > nul
|
||||
%COMPOSE_CMD% ps | findstr "!SERVICE_NAME!.*Up" > nul
|
||||
if errorlevel 1 (
|
||||
if !total_wait! LSS !MAX_WAIT_SECONDS! (
|
||||
echo 容器尚未就绪,已等待!total_wait!秒,继续等待... | Container not ready yet, waited for !total_wait! seconds, continuing to wait...
|
||||
echo 容器尚未就绪,已等待!total_wait!秒,继续等待...
|
||||
echo Container not ready yet, waited for !total_wait! seconds, continuing to wait...
|
||||
goto :wait_loop
|
||||
) else (
|
||||
echo 错误 | Error:容器启动超时,已等待!MAX_WAIT_SECONDS!秒 | Container startup timeout, waited for !MAX_WAIT_SECONDS! seconds
|
||||
echo 请检查Docker容器状态 | Please check Docker container status:docker-compose ps
|
||||
echo 错误:容器启动超时,已等待!MAX_WAIT_SECONDS!秒
|
||||
echo Error: Container startup timeout, waited for !MAX_WAIT_SECONDS! seconds
|
||||
echo 请检查Docker容器状态:%COMPOSE_CMD% ps
|
||||
echo Please check Docker container status: %COMPOSE_CMD% ps
|
||||
exit /b 1
|
||||
)
|
||||
) else (
|
||||
echo 容器已就绪,共等待了!total_wait!秒 | Container is ready, waited for !total_wait! seconds in total
|
||||
echo 容器已就绪,共等待了!total_wait!秒
|
||||
echo Container is ready, waited for !total_wait! seconds in total
|
||||
)
|
||||
)
|
||||
|
||||
REM 检查容器中是否存在xvfb-python命令 | Check if xvfb-python command exists in container
|
||||
echo 检查容器中的命令... | Checking commands in container...
|
||||
docker-compose exec -T !SERVICE_NAME! which !PYTHON_CMD! > nul 2>&1
|
||||
REM 检查容器中是否存在xvfb-python命令
|
||||
REM Check if xvfb-python command exists in container
|
||||
echo 检查容器中的命令...
|
||||
echo Checking commands in container...
|
||||
%COMPOSE_CMD% exec -T !SERVICE_NAME! which !PYTHON_CMD! > nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo 警告 | Warning:容器中未找到!PYTHON_CMD!命令,尝试使用python替代 | !PYTHON_CMD! command not found in container, trying to use python instead
|
||||
echo 警告:容器中未找到!PYTHON_CMD!命令,尝试使用python替代
|
||||
echo Warning: !PYTHON_CMD! command not found in container, trying to use python instead
|
||||
set PYTHON_CMD=python
|
||||
|
||||
REM 检查python命令是否存在 | Check if python command exists
|
||||
docker-compose exec -T !SERVICE_NAME! which python > nul 2>&1
|
||||
REM 检查python命令是否存在
|
||||
REM Check if python command exists
|
||||
%COMPOSE_CMD% exec -T !SERVICE_NAME! which python > nul 2>&1
|
||||
if errorlevel 1 (
|
||||
echo 错误 | Error:容器中未找到python命令 | python command not found in container
|
||||
echo 请检查容器配置 | Please check container configuration
|
||||
echo 错误:容器中未找到python命令
|
||||
echo Error: python command not found in container
|
||||
echo 请检查容器配置
|
||||
echo Please check container configuration
|
||||
exit /b 1
|
||||
)
|
||||
)
|
||||
|
||||
REM 在容器中运行指定的脚本,传递查询参数 | Run the specified script in container, passing query parameter
|
||||
echo 在Docker容器中使用!PYTHON_CMD!运行脚本... | Running script in Docker container using !PYTHON_CMD!...
|
||||
docker-compose exec -T !SERVICE_NAME! !PYTHON_CMD! !SCRIPT_NAME! "!QUERY!"
|
||||
REM 在容器中运行指定的脚本,传递查询参数
|
||||
REM Run the specified script in container, passing query parameter
|
||||
echo 在Docker容器中使用!PYTHON_CMD!运行脚本...
|
||||
echo Running script in Docker container using !PYTHON_CMD!...
|
||||
%COMPOSE_CMD% exec -T !SERVICE_NAME! !PYTHON_CMD! !SCRIPT_NAME! "!QUERY!"
|
||||
|
||||
if errorlevel 0 (
|
||||
echo 查询完成! | Query completed!
|
||||
echo 查询完成!
|
||||
echo Query completed!
|
||||
) else (
|
||||
echo 查询执行失败,请检查错误信息。 | Query execution failed, please check error messages.
|
||||
echo 查询执行失败,请检查错误信息。
|
||||
echo Query execution failed, please check error messages.
|
||||
)
|
||||
|
||||
pause
|
||||
Loading…
x
Reference in New Issue
Block a user