File size: 3,102 Bytes
463f868
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
@echo off
setlocal
cd /d "%~dp0"
echo ==========================================
echo Rabuka Simulator Startup
echo ==========================================

echo [1/3] Checking dependencies...
where cargo >nul 2>&1
if %errorlevel% neq 0 goto NO_CARGO

where uv >nul 2>&1
if %errorlevel% neq 0 goto NO_UV

echo [2/3] Cleaning up processes...
:: Kill other instances of this script (using title/command line filtering)
powershell -NoProfile -Command "$ppid = (Get-CimInstance Win32_Process -Filter \"ProcessId = $PID\").ParentProcessId; Get-CimInstance Win32_Process -Filter \"Name = 'cmd.exe'\" | Where-Object { $_.CommandLine -like '*start_server.bat*' -and $_.ProcessId -ne $PID -and $_.ProcessId -ne $ppid } | ForEach-Object { Stop-Process -Id $_.ProcessId -Force -ErrorAction SilentlyContinue }"

taskkill /F /IM rabuka_launcher.exe /T 2>nul
:: Simplified PowerShell cleanup - Protecting browsers
powershell -NoProfile -Command "Get-NetTCPConnection -LocalPort 8000,8080,8888,3000,5000 -ErrorAction SilentlyContinue | ForEach-Object { $p = Get-Process -Id $_.OwningProcess -ErrorAction SilentlyContinue; if ($p -and $p.ProcessName -notmatch 'chrome|msedge|firefox|brave|browser') { Stop-Process -Id $_.OwningProcess -Force -ErrorAction SilentlyContinue } }"

echo.
echo [3/3] Preparing Environment...
if not exist "data\cards.json" goto NO_DATA

echo Compiling Card Data...
uv run python -m compiler.main --quiet
if %errorlevel% neq 0 goto CMD_FAIL

:: Handle arguments
set DO_FULL=0
set DEBUG_ARG=
for %%a in (%*) do (
    if "%%a"=="--full" set DO_FULL=1
    if "%%a"=="--debug" set DEBUG_ARG=--debug
    if "%%a"=="-d" set DEBUG_ARG=--debug
)

if %DO_FULL% neq 1 goto SKIP_MATURIN
echo Building Python Extension (Maturin)...
uv run maturin develop
if %errorlevel% neq 0 goto CMD_FAIL
goto SYNC_ASSETS

:SKIP_MATURIN
echo Skipping Maturin build (use --full to build Python extension).

:SYNC_ASSETS
echo Synchronizing Frontend Assets...
uv run python tools/sync_launcher_assets.py
if %errorlevel% neq 0 goto CMD_FAIL

echo.
echo Starting Rabuka Simulator Server (Rust)...
echo NOTE: Using Rust Launcher as verified Source of Truth.
if "%DEBUG_ARG%"=="--debug" echo [DEBUG MODE ENABLED]
echo.

pushd launcher
cargo run --release --features nn --bin rabuka_launcher -- %DEBUG_ARG%
echo.
echo TIP: For live frontend editing, run 'npm run dev' in frontend/web_ui
set "EXIT_CODE=%errorlevel%"
popd

:: If it's a normal exit (0) or a Ctrl+C exit (non-zero common codes), go to END
if %EXIT_CODE% equ 0 goto END
if %EXIT_CODE% equ -1073741510 goto END
if %EXIT_CODE% equ 3221225786 goto END

:: Otherwise it's a real failure
goto CMD_FAIL

:NO_CARGO
echo ERROR: 'cargo' not found. Please install Rust.
pause
exit /b 1

:NO_UV
echo ERROR: 'uv' not found. Please install uv.
pause
exit /b 1

:NO_DATA
echo ERROR: data\cards.json not found!
pause
exit /b 1

:CMD_FAIL
echo.
echo [!] ERROR: A command failed. Check output above for details.
pause
exit /b 1

:END
echo.
echo Server session ended.
exit /b 0