fix: start hermes gateway for telegram runtime

This commit is contained in:
Felipe Domingues 2026-05-28 15:06:33 -03:00
parent 7718920777
commit 2d48a02271
2 changed files with 63 additions and 2 deletions

View file

@ -24,6 +24,7 @@ GATEWAY_ALLOW_ALL_USERS=false
HERMES_SOUL_OVERRIDE=Your custom soul prompt here HERMES_SOUL_OVERRIDE=Your custom soul prompt here
HERMES_STT_PROVIDER=local HERMES_STT_PROVIDER=local
HERMES_TTS_PROVIDER=disabled HERMES_TTS_PROVIDER=disabled
HERMES_GATEWAY_ENABLED=auto
OLLAMA_API_KEY=your-ollama-api-key OLLAMA_API_KEY=your-ollama-api-key
PORT=8642 PORT=8642
TELEGRAM_BOT_TOKEN=your-bot-token TELEGRAM_BOT_TOKEN=your-bot-token
@ -40,6 +41,10 @@ MIKA_INTERNAL_FUNCTION_SECRET=shared-internal-secret
`MIKA_PLATFORM_FUNCTIONS_BASE_URL` or `SUPABASE_URL` is present. The Mika `MIKA_PLATFORM_FUNCTIONS_BASE_URL` or `SUPABASE_URL` is present. The Mika
platform provisions all of these automatically for managed Railway services. platform provisions all of these automatically for managed Railway services.
`HERMES_GATEWAY_ENABLED=auto` starts `hermes gateway run` whenever
`TELEGRAM_BOT_TOKEN` is present, so the container consumes Telegram polling in
addition to serving the dashboard/proxy runtime API.
## Validation ## Validation
```bash ```bash

View file

@ -15,6 +15,10 @@ STT_PROVIDER="${HERMES_STT_PROVIDER:-local}"
STT_LOCAL_MODEL="${HERMES_STT_LOCAL_MODEL:-base}" STT_LOCAL_MODEL="${HERMES_STT_LOCAL_MODEL:-base}"
STT_OPENAI_MODEL="${HERMES_STT_OPENAI_MODEL:-whisper-1}" STT_OPENAI_MODEL="${HERMES_STT_OPENAI_MODEL:-whisper-1}"
TTS_PROVIDER="${HERMES_TTS_PROVIDER:-disabled}" TTS_PROVIDER="${HERMES_TTS_PROVIDER:-disabled}"
GATEWAY_ENABLED="${HERMES_GATEWAY_ENABLED:-auto}"
GATEWAY_ARGS="${HERMES_GATEWAY_ARGS:---replace}"
HERMES_ALLOW_ROOT_GATEWAY="${HERMES_ALLOW_ROOT_GATEWAY:-1}"
export HERMES_ALLOW_ROOT_GATEWAY
mkdir -p "$HERMES_HOME" mkdir -p "$HERMES_HOME"
@ -83,12 +87,27 @@ echo "[entrypoint] Hermes interno: $INTERNAL_HOST:$INTERNAL_PORT"
echo "[entrypoint] Proxy público: $PUBLIC_HOST:$PUBLIC_PORT" echo "[entrypoint] Proxy público: $PUBLIC_HOST:$PUBLIC_PORT"
echo "[entrypoint] Iniciando Hermes original..." echo "[entrypoint] Iniciando Hermes original..."
PIDS=()
cleanup() {
local status=$?
trap - EXIT INT TERM
if [ "${#PIDS[@]}" -gt 0 ]; then
kill "${PIDS[@]}" 2>/dev/null || true
wait "${PIDS[@]}" 2>/dev/null || true
fi
exit "$status"
}
trap cleanup EXIT INT TERM
hermes dashboard \ hermes dashboard \
--host "$INTERNAL_HOST" \ --host "$INTERNAL_HOST" \
--port "$INTERNAL_PORT" \ --port "$INTERNAL_PORT" \
--no-open & --no-open &
HERMES_PID="$!" HERMES_PID="$!"
PIDS+=("$HERMES_PID")
echo "[entrypoint] Aguardando Hermes responder em $INTERNAL_HOST:$INTERNAL_PORT..." echo "[entrypoint] Aguardando Hermes responder em $INTERNAL_HOST:$INTERNAL_PORT..."
@ -113,9 +132,46 @@ if ! kill -0 "$HERMES_PID" 2>/dev/null; then
exit 1 exit 1
fi fi
should_start_gateway=false
case "$GATEWAY_ENABLED" in
true|1|yes|on)
should_start_gateway=true
;;
false|0|no|off)
should_start_gateway=false
;;
auto|"")
if [ -n "${TELEGRAM_BOT_TOKEN:-}" ]; then
should_start_gateway=true
fi
;;
*)
echo "[entrypoint] HERMES_GATEWAY_ENABLED inválido: $GATEWAY_ENABLED"
exit 1
;;
esac
if [ "$should_start_gateway" = "true" ]; then
echo "[entrypoint] Iniciando gateway de mensagens Hermes..."
# shellcheck disable=SC2086
hermes gateway run $GATEWAY_ARGS &
GATEWAY_PID="$!"
PIDS+=("$GATEWAY_PID")
else
echo "[entrypoint] Gateway de mensagens desabilitado"
fi
echo "[entrypoint] Iniciando proxy público em $PUBLIC_HOST:$PUBLIC_PORT..." echo "[entrypoint] Iniciando proxy público em $PUBLIC_HOST:$PUBLIC_PORT..."
exec python /opt/hermes-custom/skills_api.py \ python /opt/hermes-custom/skills_api.py \
--host "$PUBLIC_HOST" \ --host "$PUBLIC_HOST" \
--port "$PUBLIC_PORT" \ --port "$PUBLIC_PORT" \
--target "http://$INTERNAL_HOST:$INTERNAL_PORT" --target "http://$INTERNAL_HOST:$INTERNAL_PORT" &
PROXY_PID="$!"
PIDS+=("$PROXY_PID")
wait -n "${PIDS[@]}"
EXITED_STATUS=$?
echo "[entrypoint] Um processo do runtime encerrou (status=$EXITED_STATUS); finalizando container"
exit "$EXITED_STATUS"