NO docker
This commit is contained in:
46
start_backend.bat
Normal file
46
start_backend.bat
Normal file
@@ -0,0 +1,46 @@
|
||||
@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
|
Reference in New Issue
Block a user