b2ea6c727c
在 alembic upgrade head 之前调用 scripts.ensure_pg:没起会自动拉起 Docker + PG 容器,失败即退出(run.bat 判 errorlevel)。顺带订正过时的 "sqlite" 注释。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
49 lines
1.6 KiB
Batchfile
49 lines
1.6 KiB
Batchfile
@echo off
|
|
REM Local dev startup script (Windows) - mirror of run.sh
|
|
REM
|
|
REM Usage:
|
|
REM cd shaguabijia-app-server
|
|
REM run.bat
|
|
REM
|
|
REM Listens on 0.0.0.0:8770 (works for both real device via adb reverse
|
|
REM and LAN). Auto-reload on code change.
|
|
REM
|
|
REM Prerequisite (first time):
|
|
REM conda activate pricebot ^&^& pip install -e .
|
|
REM copy .env.example .env ^&^& fill JWT_SECRET_KEY
|
|
REM
|
|
REM This file is the Windows-native peer of run.sh. Keeping run.sh untouched
|
|
REM avoids CRLF/encoding fights every time someone bash-runs the .sh on Win.
|
|
|
|
cd /d "%~dp0"
|
|
|
|
REM Prefer the project virtualenv (.venv) so we never inherit a wrong
|
|
REM global/conda interpreter. FastAPI<0.115 on Pydantic 2.12 crashes at import
|
|
REM with "'FieldInfo' object has no attribute 'in_'". Falls back to PATH python.
|
|
set "PY=python"
|
|
if exist "%~dp0.venv\Scripts\python.exe" set "PY=%~dp0.venv\Scripts\python.exe"
|
|
|
|
if not exist .env (
|
|
echo [X] Missing .env. Run: copy .env.example .env and fill JWT_SECRET_KEY ^(plus MT_CPS_* if you test Meituan^)
|
|
exit /b 1
|
|
)
|
|
|
|
if not exist data mkdir data
|
|
|
|
REM Ensure local Docker PostgreSQL is up (auto-starts Docker + PG container if needed)
|
|
call "%PY%" -m scripts.ensure_pg
|
|
if errorlevel 1 (
|
|
echo [X] ensure_pg failed ^(PostgreSQL not ready^)
|
|
exit /b %errorlevel%
|
|
)
|
|
|
|
REM Build/upgrade schema (idempotent; no-op if already at head)
|
|
call "%PY%" -m alembic upgrade head
|
|
if errorlevel 1 (
|
|
echo [X] alembic upgrade head failed
|
|
exit /b %errorlevel%
|
|
)
|
|
|
|
REM Long-running foreground process. Ctrl+C to stop.
|
|
"%PY%" -m uvicorn app.main:app --host 0.0.0.0 --port 8770 --reload
|