Files
jdy_fastapi/start_prod.bat
panda f0fcea03bb 1.新增gitignore文件
2.新启动脚本制作
2026-01-30 11:41:05 +08:00

54 lines
1.5 KiB
Batchfile
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
title 简道云监听服务 端口5000
:: 切换到应用所在目录(与原始脚本一致)
cd /d "C:\Users\Administrator\Desktop\简道云\简道云"
:: 激活Anaconda基础环境(或你指定的环境)
call C:\ProgramData\anaconda3\Scripts\activate.bat
if %errorlevel% neq 0 (
echo 激活Anaconda环境失败,请检查环境配置。
pause
exit /b 1
)
:: 验证Python是否可用
python --version >nul 2>&1
if %errorlevel% neq 0 (
echo 无法找到Python,请检查Anaconda环境是否正确安装。
pause
exit /b 1
)
:: 验证uvicorn是否已安装(可选但推荐)
python -c "import uvicorn" >nul 2>&1
if %errorlevel% neq 0 (
echo 错误:未检测到 uvicorn。请运行以下命令安装:
echo conda install -c conda-forge uvicorn fastapi
echo
echo pip install "uvicorn[standard]" fastapi
pause
exit /b 1
)
:: 设置默认参数(允许通过环境变量覆盖)
if "%HOST%"=="" set HOST=0.0.0.0
if "%PORT%"=="" set PORT=5000
if "%WORKERS%"=="" set WORKERS=1
if "%LOG_LEVEL%"=="" set LOG_LEVEL=info
set APP_MODULE=main:app
echo.
echo 启动简道云 FastAPI 服务...
echo 模块: %APP_MODULE%
echo 地址: http://%HOST%:%PORT%
echo 进程数: %WORKERS% Windows建议设为1
echo 日志级别: %LOG_LEVEL%
echo.
:: 使用 python -m uvicorn 确保调用当前环境中的 uvicorn
python -m uvicorn %APP_MODULE% --host %HOST% --port %PORT% --workers %WORKERS% --log-level %LOG_LEVEL%
:: 服务退出后暂停,便于查看日志
pause