| set -euo pipefail | |
| DBOPS_ROOT=${DBOPS_ROOT:-/data/adaptai/platform/dbops} | |
| SECRETS_DIR=${SECRETS_DIR:-/data/adaptai/secrets/dataops} | |
| JAVA_HOME=${JAVA_HOME:-$DBOPS_ROOT/binaries/java/jre11} | |
| PATH="$JAVA_HOME/bin:${PATH:-/usr/bin:/bin}" | |
| export DBOPS_ROOT SECRETS_DIR JAVA_HOME PATH | |
| CFG="$DBOPS_ROOT/run/janusgraph/gremlin-server.runtime.yaml" | |
| BIN_DIR="$DBOPS_ROOT/binaries/janusgraph/bin" | |
| STARTER="$DBOPS_ROOT/tools/start_janusgraph_daemon.sh" | |
| cleanup() { | |
| echo "[janusgraph] stopping via gremlin-server.sh stop" | |
| if [ -x "$BIN_DIR/gremlin-server.sh" ]; then | |
| "$BIN_DIR/gremlin-server.sh" stop "$CFG" || true | |
| elif [ -x "$BIN_DIR/janusgraph-server.sh" ]; then | |
| "$BIN_DIR/janusgraph-server.sh" stop "$CFG" || true | |
| fi | |
| } | |
| trap cleanup TERM INT | |
| # Render + start in daemon mode (backgrounded by script) | |
| bash "$STARTER" | |
| # Poll TCP port; exit when closed | |
| host=127.0.0.1; port=17002 | |
| echo "[janusgraph] monitoring $host:$port" | |
| while true; do | |
| if timeout 1 bash -lc "</dev/tcp/$host/$port" 2>/dev/null; then | |
| sleep 2 | |
| else | |
| echo "[janusgraph] port closed; exiting" | |
| exit 1 | |
| fi | |
| done | |