File size: 1,162 Bytes
851f2ed
 
 
695b33f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
851f2ed
 
695b33f
 
 
 
 
851f2ed
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
#!/usr/bin/env bash
set -euo pipefail

HOST="${LIGHTRAG_HOST:-127.0.0.1}"
ROOT="${LIGHTRAG_STORAGE_ROOT:-data/rag_storage}"
GRAPHS="${LIGHTRAG_GRAPHS:-romania:9621}"
API_PORT="${PORT:-${API_PORT:-8000}}"

echo "πŸš€ LIGHTRAG_GRAPHS=${GRAPHS}"
echo "πŸ“ Storage root: ${ROOT}"

PIDS=()
trap 'kill -TERM ${PIDS[@]:-} 2>/dev/null || true; wait ${PIDS[@]:-} 2>/dev/null || true' EXIT INT TERM

ENDPOINTS=()

IFS=',' read -r -a items <<<"${GRAPHS}"
for item in "${items[@]}"; do
  IFS=':' read -r id port <<<"${item}"
  dir="${ROOT}/${id}"
  mkdir -p "${dir}"

  echo "➑️  Start LightRAG '${id}' on ${HOST}:${port} (dir=${dir})"
  lightrag-server --host "${HOST}" --port "${port}" --working-dir "${dir}" &
  PIDS+=("$!")

  echo "   ⏳ Waiting health..."
  for _ in {1..30}; do
    curl -fsS "http://${HOST}:${port}/health" >/dev/null 2>&1 && { echo "   βœ… ${id} ready"; break; }
    sleep 2
  done

  ENDPOINTS+=("${id}=http://${HOST}:${port}")
done

export LIGHTRAG_ENDPOINTS="$(IFS=,; echo "${ENDPOINTS[*]}")"
export PORT="${API_PORT}"

echo "βœ… LIGHTRAG_ENDPOINTS=${LIGHTRAG_ENDPOINTS}"
echo "πŸš€ Starting API on 0.0.0.0:${PORT} ..."
python agent_api.py