-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcortex.bat
More file actions
102 lines (88 loc) · 2.19 KB
/
cortex.bat
File metadata and controls
102 lines (88 loc) · 2.19 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
@echo off
title Cortex Dev Console
:menu
cls
echo.
echo ========================================
echo Cortex Dev Server Console
echo ========================================
echo.
echo [1] Start servers
echo [2] Stop servers
echo [3] Restart servers
echo [4] Status check
echo [5] Exit
echo.
set /p choice=" Select option: "
if "%choice%"=="1" goto start
if "%choice%"=="2" goto stop
if "%choice%"=="3" goto restart
if "%choice%"=="4" goto status
if "%choice%"=="5" goto quit
echo Invalid option.
timeout /t 2 /nobreak >nul
goto menu
:start
echo.
echo Starting Cortex servers...
:: Kill any existing instances first
call :dokill
:: Start API server
echo [1/2] Starting API on http://127.0.0.1:8055 ...
start "Cortex-API" /min cmd /c "cd /d U:\1. Projects\Cortex && python -m uvicorn api.main:app --host 127.0.0.1 --port 8055 --log-level warning"
timeout /t 3 /nobreak >nul
:: Start Viewer
echo [2/2] Starting Viewer on http://localhost:5173 ...
start "Cortex-Viewer" /min cmd /c "cd /d U:\1. Projects\Cortex\viewer && npm run dev"
timeout /t 3 /nobreak >nul
echo.
echo ----------------------------------------
echo API: http://127.0.0.1:8055
echo Viewer: http://localhost:5173
echo Docs: http://127.0.0.1:8055/docs
echo ----------------------------------------
echo.
pause
goto menu
:stop
echo.
call :dokill
echo.
pause
goto menu
:restart
echo.
echo Restarting...
call :dokill
timeout /t 2 /nobreak >nul
goto start
:status
echo.
echo Checking servers...
echo.
curl -s http://127.0.0.1:8055/health >nul 2>&1
if %errorlevel%==0 (
echo API: RUNNING
) else (
echo API: STOPPED
)
curl -s http://localhost:5173 >nul 2>&1
if %errorlevel%==0 (
echo Viewer: RUNNING
) else (
echo Viewer: STOPPED
)
echo.
pause
goto menu
:dokill
echo Stopping existing servers...
taskkill /F /FI "WINDOWTITLE eq Cortex-API" >nul 2>&1
taskkill /F /FI "WINDOWTITLE eq Cortex-Viewer" >nul 2>&1
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":8055" ^| findstr "LISTENING"') do taskkill /F /PID %%a >nul 2>&1
for /f "tokens=5" %%a in ('netstat -ano ^| findstr ":5173" ^| findstr "LISTENING"') do taskkill /F /PID %%a >nul 2>&1
echo Servers stopped.
exit /b
:quit
call :dokill
exit