代码拉取完成,页面将自动刷新
同步操作将从 blackldh/DevOpsGPT 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
@echo off
setlocal enabledelayedexpansion
call :get_python3
if errorlevel 1 (
echo Python 3.7 or higher is required to run DevOpsGPT.
exit /b 1
)
copy .\.github\hooks\pre-commit .\.git\hooks\
echo Installing missing packages...
call %PYTHON_CMD% -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple -r requirements.txt
start "" %PYTHON_CMD% backend\run.py
call :start_frontend %PYTHON_CMD%
call :kill_by_port %%BACKEND_PORT%%
exit /b 0
REM function
:get_python3
for /f "delims=" %%i in ('where python 2^>nul') do (
set "PYTHON_CMD=%%i"
goto :pyCheck
)
:pyCheck
if not defined PYTHON_CMD (
echo Python3 not found. Please install Python3.7 or higher.
exit /b 1
)
GOTO:EOF
:get_config_value
set "yaml_file=env.yaml"
set "key=%~1"
for /f "usebackq tokens=2 delims=: " %%a in (`findstr /C:"%key%:" "%yaml_file%"`) do (
set "value=%%a"
)
if not defined value (
echo Error: Key '%key%' not found in config file '%yaml_file%'. Please copy a new env.yaml from env.yaml.tpl and reconfigure it according to the documentation.
exit /b 1
)
set "%key%=!value!"
GOTO:EOF
:start_frontend
set "PYTHON_CMD=%~1"
call :get_config_value FRONTEND_PORT
call :get_config_value BACKEND_PORT
if %errorlevel%==1 (
pause
exit /b 1
)
REM Wait for the backend service to start
for /l %%i in (1, 1, 20) do (
set "response="
for /f "delims=" %%a in ('set HTTP_PROXY= ^& set HTTPS_PROXY= ^& set ALL_PROXY= ^& set http_proxy= ^& set https_proxy= ^& set all_proxy= ^& curl -s -o nul -w "%%{http_code}" http://127.0.0.1:%BACKEND_PORT%') do set "response=%%a"
echo !response!
if "!response!"=="404" (
echo.
echo Service started successfully, please use a browser to visit: http://127.0.0.1:!FRONTEND_PORT!
GOTO :starFrontend
) else (
timeout /t 5 > nul
)
)
:starFrontend
call %PYTHON_CMD% -m http.server %FRONTEND_PORT% --directory frontend
GOTO:EOF
:kill_by_port
set "port=%~1"
for /f "delims=" %%a in ('netstat -aon ^| findstr "LISTENING" ^| findstr ":!port!"') do (
set "line=%%a"
for /f "tokens=5" %%b in ("!line!") do set "pid=%%b"
)
if not defined pid (
echo The port is not in use: %port%
exit /b 1
)
taskkill /f /pid %pid%
GOTO:EOF
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。