@echo off
rem ===================================================================
rem RTGS 1 center (DC1) launcher: native infra + sequencer/4 services.
rem Docker 대신 네이티브 포터블 인프라 사용(이 PC는 가상화 미지원).
rem Services run on JDK21; global JAVA_HOME stays jdk-26 for other projects.
rem ===================================================================
call C:\ai-dev\scripts\env.cmd
set "JAVA_HOME=%JDK21_HOME%"
set "CENTER_ID=DC1"
rem 기본 단일센터(count=1, db=rtgs). 3센터 모드는 호출 전에 미리 지정:
rem   set CENTER_COUNT=3 & set POSTGRES_DB=rtgs_dc1 & run-dc1.cmd
if not defined CENTER_COUNT set "CENTER_COUNT=1"
if not defined POSTGRES_DB  set "POSTGRES_DB=rtgs"

echo [run-dc1] starting native infra (postgres:5433 / kafka:9092)...
call "%~dp0infra\start-infra-native.cmd"
echo [run-dc1] waiting for Kafka to accept connections...
timeout /t 12 /nobreak >nul

echo [run-dc1] starting services on JDK21...
start "RTGS Sequencer :8090" cmd /k "%JAVA_HOME%\bin\java -jar %~dp0backend\sequencer\build\libs\sequencer-0.1.0.jar"
start "RTGS Dior"            cmd /k "%JAVA_HOME%\bin\java -jar %~dp0backend\dior\build\libs\dior-0.1.0.jar"
start "RTGS Hermes"          cmd /k "%JAVA_HOME%\bin\java -jar %~dp0backend\hermes\build\libs\hermes-0.1.0.jar"
start "RTGS Prada"           cmd /k "%JAVA_HOME%\bin\java -jar %~dp0backend\prada\build\libs\prada-0.1.0.jar"
start "RTGS Chanel :8091"    cmd /k "%JAVA_HOME%\bin\java -jar %~dp0backend\chanel\build\libs\chanel-0.1.0.jar"
start "RTGS LouisVuitton :8099" cmd /k "%JAVA_HOME%\bin\java -jar %~dp0backend\louisvuitton\build\libs\louisvuitton-0.1.0.jar"
start "RTGS Gucci :8095"        cmd /k "%JAVA_HOME%\bin\java -jar %~dp0backend\gucci\build\libs\gucci-0.1.0.jar"

echo.
echo [run-dc1] launched. Chanel API: http://localhost:8091
echo   POST http://localhost:8091/pay/customer   (pacs.008 XML)
echo   GET  http://localhost:8091/inquiry/{bmi}
echo   GET  http://localhost:8091/accounts
echo   stop services: close the windows;  stop infra: run stop-dc1.cmd
