diff --git a/ai/compose.yml b/ai/compose.yml index 3126c2b..89dceca 100755 --- a/ai/compose.yml +++ b/ai/compose.yml @@ -32,9 +32,11 @@ services: - default container_name: hermes entrypoint: ["/bin/bash", "-c", - "bash /opt/data/hermes-tools/install.sh && bash /opt/data/hermes-tools/run-multi-gateways.sh && exec /usr/bin/tini -g -- /opt/hermes/docker/entrypoint.sh \"$@\"", + "bash /opt/data/hermes-tools/install.sh && bash /usr/local/bin/run-multi-gateways.sh && exec /usr/bin/tini -g -- /opt/hermes/docker/entrypoint.sh \"$@\"", "hermes-entrypoint"] restart: always + # Gateway run enables the internal API server on port 8642 + command: gateway run environment: - OLLAMA_HOST=http://ollama:11434 - HERMES_DASHBOARD=1 diff --git a/ai/hermes/Dockerfile b/ai/hermes/Dockerfile index 253b9b7..dd044f9 100644 --- a/ai/hermes/Dockerfile +++ b/ai/hermes/Dockerfile @@ -76,6 +76,10 @@ os.remove(tgz) print('himalaya v1.2.0 installed') PYEOF +# ---------- Install multi-gateway launcher ---------- +# Launches one gateway process per profile (HERMES_PROFILES env var) +COPY --chmod=0755 run-multi-gateways.sh /usr/local/bin/run-multi-gateways.sh + # ---------- Runtime ---------- USER hermes ENV HERMES_HOME=/opt/data diff --git a/ai/hermes/run-multi-gateways.sh b/ai/hermes/run-multi-gateways.sh new file mode 100755 index 0000000..f23ac78 --- /dev/null +++ b/ai/hermes/run-multi-gateways.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Multi-gateway launcher for HERMES_PROFILES env var. +# Reads comma-separated profile names, spawns one gateway per profile. +# Designed to run before the main entrypoint — gateways run in background. +set -e + +if [ -z "${HERMES_PROFILES}" ]; then + echo "HERMES_PROFILES not set — skipping multi-gateway launch" + exit 0 +fi + +# Source venv to make 'hermes' available (entrypoint.sh sources it later, +# but we need it NOW for the background gateways) +HERMES_BIN="/opt/hermes/.venv/bin/hermes" +if [ ! -x "$HERMES_BIN" ]; then + echo "ERROR: hermes binary not found at $HERMES_BIN" + exit 1 +fi + +mkdir -p /opt/data/logs + +IFS=',' read -ra PROFILES <<< "${HERMES_PROFILES}" +for profile in "${PROFILES[@]}"; do + profile="$(echo "${profile}" | xargs)" # trim whitespace + [ -z "${profile}" ] && continue + + echo "Starting gateway for profile: ${profile}" + nohup env API_SERVER_ENABLED=false API_SERVER_KEY= gosu hermes "$HERMES_BIN" --profile "${profile}" gateway run \ + >> "/opt/data/logs/gateway-${profile}.log" 2>&1 & +done + +echo "All gateways launched: ${HERMES_PROFILES}"