Shell prefix didn't work with nohup+gosu chain - Docker compose env var API_SERVER_ENABLED=true leaked through. Using 'env' command guarantees the override is in the child process env.
33 lines
1.0 KiB
Bash
Executable File
33 lines
1.0 KiB
Bash
Executable File
#!/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 gosu hermes "$HERMES_BIN" --profile "${profile}" gateway run \
|
|
>> "/opt/data/logs/gateway-${profile}.log" 2>&1 &
|
|
done
|
|
|
|
echo "All gateways launched: ${HERMES_PROFILES}"
|