Files
Document_translator_V2_nodo…/start_backend.bat
beabigegg 4cace93934 NO docker
2025-10-02 18:50:53 +08:00

47 lines
1.3 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
REM ============================================
REM PANJIT Document Translator V2
REM 後端服務啟動腳本 (Windows)
REM ============================================
echo ========================================
echo PANJIT Document Translator V2
echo 後端服務啟動 (端口 12010)
echo ========================================
echo.
REM 設定環境變數
set FLASK_ENV=production
set FLASK_DEBUG=false
set PORT=12010
set HOST=0.0.0.0
echo [INFO] 載入環境變數...
echo [INFO] 服務端口: %PORT%
echo.
REM 檢查 Python 虛擬環境
if exist venv\Scripts\activate.bat (
echo [INFO] 啟動虛擬環境...
call venv\Scripts\activate.bat
) else (
echo [警告] 未找到虛擬環境 venv使用系統 Python
)
echo.
echo [INFO] 啟動 Flask 應用 (Gunicorn)...
echo [INFO] 按 Ctrl+C 停止服務
echo.
REM 使用 Gunicorn 啟動 (Windows 可能需要改用 waitress)
python -c "import gunicorn" >nul 2>&1
if %errorlevel% equ 0 (
gunicorn --bind %HOST%:%PORT% --workers 4 --worker-class gthread --threads 4 --timeout 300 --access-logfile logs/access.log --error-logfile logs/error.log wsgi:app
) else (
echo [INFO] Gunicorn 不可用,使用 waitress-serve...
pip install waitress >nul 2>&1
waitress-serve --host=%HOST% --port=%PORT% --threads=8 wsgi:app
)
pause