@echo off
rem ===================================================================
rem RTGS 로그관리 ELK 네이티브 기동 (Docker 없이). 각각 새 창으로 뜬다.
rem   Elasticsearch :9200  (데이터 home\es-data)
rem   Logstash      :5000  (서비스 Logback TCP 수신 -> ES rtgs-logs-*)
rem   Kibana        :5601  (로그 조회 UI)  -> http://localhost:5601 (Discover > RTGS Logs)
rem 주의: ELK는 메모리를 많이 쓴다(ES/Logstash 각 ~1GB). 서비스+인프라와 동시 구동 시 여유 확인.
rem ===================================================================
call C:\ai-dev\scripts\env.cmd
set "ES=%DEV_HOME%\apps\elasticsearch-8.15.2"
set "LS=%DEV_HOME%\apps\logstash-8.15.2"
set "KB=%DEV_HOME%\apps\kibana-8.15.2"

echo [elk] starting Elasticsearch :9200 (new window)...
start "RTGS Elasticsearch :9200" cmd /k "set ES_JAVA_HOME=%ES%\jdk&& %ES%\bin\elasticsearch.bat"

echo [elk] waiting for ES to come up...
timeout /t 40 /nobreak >nul

echo [elk] starting Logstash :5000 (new window)...
start "RTGS Logstash :5000" cmd /k "set LS_JAVA_HOME=%LS%\jdk&& %LS%\bin\logstash.bat -f %DEV_HOME%\home\logstash\rtgs.conf --path.data %DEV_HOME%\home\logstash\data"

echo [elk] starting Kibana :5601 (new window; ~1 min to be ready)...
start "RTGS Kibana :5601" cmd /k "%KB%\bin\kibana.bat"

echo.
echo [elk] launched. Kibana: http://localhost:5601  (Discover ^> RTGS Logs, index rtgs-logs-*)
