-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.bat
More file actions
83 lines (73 loc) · 2.47 KB
/
Copy pathrun.bat
File metadata and controls
83 lines (73 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@echo off
:: ============================================================
:: DOTMappers AI Assessment — Single-Command Windows Launcher
:: Usage: run.bat
:: ============================================================
echo.
echo ================================================
echo DOTMappers AI Support Analytics
echo Starting up...
echo ================================================
echo.
:: Check Python is available
where python >nul 2>&1
if errorlevel 1 (
echo [ERROR] Python not found in PATH. Please install Python 3.11+
exit /b 1
)
:: Create .env from example if not present
if not exist ".env" (
if exist ".env.example" (
copy ".env.example" ".env" >nul
echo [SETUP] Created .env from .env.example
echo [SETUP] Please edit .env and add your API keys, then re-run.
echo.
)
)
:: Install dependencies if needed
echo [SETUP] Checking dependencies...
pip install -r requirements.txt -q --disable-pip-version-check
if errorlevel 1 (
echo [ERROR] Failed to install dependencies.
exit /b 1
)
echo [SETUP] Dependencies OK.
echo.
:: Start FastAPI in background
echo [API] Starting FastAPI on http://localhost:8000 ...
start /B "" python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --log-level info
:: Wait for FastAPI to be ready
echo [API] Waiting for API health check...
set RETRY=0
:HEALTH_LOOP
timeout /t 1 /nobreak >nul
curl -sf http://localhost:8000/health >nul 2>&1
if not errorlevel 1 goto API_READY
set /A RETRY+=1
if %RETRY% GEQ 15 (
echo [WARN] FastAPI health check timed out after 15s.
echo [WARN] Streamlit will run in in-memory mode.
goto START_UI
)
goto HEALTH_LOOP
:API_READY
echo [API] FastAPI is healthy! ^(http://localhost:8000/docs^)
:START_UI
:: Start Streamlit
echo [UI] Starting Streamlit on http://localhost:8501 ...
echo.
echo ================================================
echo ACCESS POINTS:
echo API: http://localhost:8000
echo API Docs: http://localhost:8000/docs
echo UI: http://localhost:8501
echo ================================================
echo.
echo Press CTRL+C to stop all services.
echo.
python -m streamlit run streamlit_app.py --server.port 8501 --server.address 0.0.0.0
:: When Streamlit exits, kill background uvicorn
echo.
echo [Shutdown] Stopping FastAPI...
for /f "tokens=5" %%a in ('netstat -aon ^| find ":8000" ^| find "LISTENING"') do taskkill /PID %%a /F >nul 2>&1
echo [Shutdown] All services stopped.