File size: 1,876 Bytes
93be2a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
set -euo pipefail

# Render JanusGraph CQL properties with secrets and launch Gremlin Server.
# Defaults align with your new dbops tree.

DBOPS_ROOT="${DBOPS_ROOT:-/data/adaptai/platform/dbops}"
SECRETS_DIR="${SECRETS_DIR:-/data/adaptai/secrets/dataops}"

CONF_DIR="$DBOPS_ROOT/configs/janusgraph"
RUNTIME_DIR="$DBOPS_ROOT/run/janusgraph"
mkdir -p "$RUNTIME_DIR"

TEMPLATE="$CONF_DIR/janusgraph-cql.properties"
OUT="$RUNTIME_DIR/janusgraph-cql.runtime.properties"

# Load secrets (.env key=val) into env without overriding existing vars
if [[ -f "$SECRETS_DIR/.env" ]]; then
  while IFS='=' read -r k v; do
    [[ -z "$k" ]] && continue
    [[ "$k" =~ ^# ]] && continue
    [[ -z "$v" ]] && continue
    if [[ -z "${!k-}" ]]; then export "$k"="$v"; fi
  done < <(grep -v '^#' "$SECRETS_DIR/.env" | sed '/^$/d')
fi

if [[ -z "${SCYLLA_USER:-}" || -z "${SCYLLA_PASS:-}" ]]; then
  echo "[janus] Missing SCYLLA_USER or SCYLLA_PASS in $SECRETS_DIR/.env" >&2
  exit 1
fi

# Simple env substitution for ${VAR} placeholders
awk '{print}' "$TEMPLATE" \
 | sed "s#\${SCYLLA_USER}#${SCYLLA_USER}#g" \
 | sed "s#\${SCYLLA_PASS}#${SCYLLA_PASS}#g" \
 > "$OUT"

echo "[janus] Rendered: $OUT"

# Launch Gremlin Server with rendered properties
GREMLIN_YAML="$CONF_DIR/gremlin-server.yaml"
if [[ -n "${START_GREMLIN:-1}" && "${START_GREMLIN}" != "0" ]]; then
  echo "[janus] Starting Gremlin Server on port configured in $GREMLIN_YAML"
  # Assume janusgraph distribution bin/gremlin-server.sh is on PATH or under dbops/bin
  if command -v gremlin-server.sh >/dev/null 2>&1; then
    exec gremlin-server.sh start "$GREMLIN_YAML"
  elif [[ -x "$DBOPS_ROOT/bin/gremlin-server.sh" ]]; then
    exec "$DBOPS_ROOT/bin/gremlin-server.sh" start "$GREMLIN_YAML"
  else
    echo "[janus] gremlin-server.sh not found; start it with the above config manually." >&2
    exit 2
  fi
fi