ontology
This commit is contained in:
54
start_webserver.bat
Normal file
54
start_webserver.bat
Normal file
@@ -0,0 +1,54 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
cd /d "%SCRIPT_DIR%"
|
||||
|
||||
set "HOST=127.0.0.1"
|
||||
set "PORT=8000"
|
||||
set "URL=http://%HOST%:%PORT%/"
|
||||
set "BUNDLED_PYTHON=C:\Users\lasta\.cache\codex-runtimes\codex-primary-runtime\dependencies\python\python.exe"
|
||||
set "PYTHON_EXE="
|
||||
|
||||
if exist "%SCRIPT_DIR%.venv\Scripts\python.exe" set "PYTHON_EXE=%SCRIPT_DIR%.venv\Scripts\python.exe"
|
||||
if not defined PYTHON_EXE if exist "%SCRIPT_DIR%venv\Scripts\python.exe" set "PYTHON_EXE=%SCRIPT_DIR%venv\Scripts\python.exe"
|
||||
if not defined PYTHON_EXE if exist "%BUNDLED_PYTHON%" set "PYTHON_EXE=%BUNDLED_PYTHON%"
|
||||
|
||||
if not defined PYTHON_EXE (
|
||||
echo [OCP] Python executable not found.
|
||||
echo [OCP] Put Python 3.11+ in .venv\Scripts\python.exe or install the Codex bundled runtime.
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
"%PYTHON_EXE%" -c "import fastapi, uvicorn" >nul 2>nul
|
||||
if errorlevel 1 (
|
||||
echo [OCP] Missing Python dependencies.
|
||||
echo [OCP] Run: "%PYTHON_EXE%" -m pip install -r requirements.txt
|
||||
pause
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
powershell -NoProfile -Command "try { $r = Invoke-RestMethod -Uri '%URL%health' -TimeoutSec 2; if ($r.ok) { exit 0 } else { exit 1 } } catch { exit 1 }" >nul 2>nul
|
||||
if not errorlevel 1 (
|
||||
echo [OCP] Existing server is already running at %URL%
|
||||
start "" "%URL%"
|
||||
exit /b 0
|
||||
)
|
||||
|
||||
set "CRAWLER_DATABASE_URL=sqlite:///crawler_platform.db"
|
||||
title Ontology Crawler Web Server
|
||||
|
||||
echo [OCP] Starting server with: %PYTHON_EXE%
|
||||
echo [OCP] URL: %URL%
|
||||
echo [OCP] Press Ctrl+C to stop the server.
|
||||
|
||||
start "" "%URL%"
|
||||
"%PYTHON_EXE%" -m uvicorn crawler_platform.app.main:app --host %HOST% --port %PORT%
|
||||
|
||||
set "EXIT_CODE=%ERRORLEVEL%"
|
||||
echo.
|
||||
echo [OCP] Server stopped.
|
||||
if not "%EXIT_CODE%"=="0" echo [OCP] Exit code: %EXIT_CODE%
|
||||
pause
|
||||
exit /b %EXIT_CODE%
|
||||
Reference in New Issue
Block a user