Files
YG_FT_Platform/request/_backend.bat

39 lines
1.6 KiB
Batchfile
Raw Normal View History

@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
:: 读取配置
cd /d "%~dp0"
powershell -Command "try { $config = Get-Content ../config.json | ConvertFrom-Json; Write-Host $config.backend.host; } catch { Write-Host 'ERROR'; exit 1; }" > temp_host.txt
set /p backend_host=<temp_host.txt
powershell -Command "try { $config = Get-Content ../config.json | ConvertFrom-Json; Write-Host $config.backend.port; } catch { Write-Host 'ERROR'; exit 1; }" > temp_port.txt
set /p backend_port=<temp_port.txt
powershell -Command "try { $config = Get-Content ../config.json | ConvertFrom-Json; Write-Host $config.backend.python_path; } catch { Write-Host 'ERROR'; exit 1; }" > temp_python.txt
set /p python_path=<temp_python.txt
powershell -Command "try { $config = Get-Content ../config.json | ConvertFrom-Json; Write-Host $config.backend.main_module; } catch { Write-Host 'ERROR'; exit 1; }" > temp_module.txt
set /p main_module=<temp_module.txt
powershell -Command "try { $config = Get-Content ../config.json | ConvertFrom-Json; Write-Host $config.backend.log_level; } catch { Write-Host 'INFO'; exit 1; }" > temp_loglevel.txt
set /p log_level=<temp_loglevel.txt
del temp_host.txt temp_port.txt temp_python.txt temp_module.txt temp_loglevel.txt 2>nul
echo [后端] 启动配置:
echo [后端] 主机: !backend_host!
echo [后端] 端口: !backend_port!
echo [后端] 日志级别: !log_level!
echo [后端] 主模块: !main_module!
echo.
:: 设置环境变量
set PYTHONPATH=src
set LOGLEVEL=!log_level!
:: 启动后端服务
echo [后端] 正在启动服务...
!python_path! -m uvicorn !main_module! --host !backend_host! --port !backend_port!
pause