| #!/usr/bin/env bash |
| |
| |
| set -uo pipefail |
|
|
| III_URL="${III_URL:-ws://127.0.0.1:49134}" |
| III_CONFIG="${III_CONFIG:-/opt/evetool/iii-config.yaml}" |
| LOG_DIR="/opt/evetool/data" |
| mkdir -p "$LOG_DIR" |
|
|
| echo "[entrypoint] starting iii engine (config=$III_CONFIG)" |
| iii --config "$III_CONFIG" >"$LOG_DIR/iii.log" 2>&1 & |
| III_PID=$! |
|
|
| |
| echo "[entrypoint] waiting for iii engine ws port 49134..." |
| for i in $(seq 1 30); do |
| if (echo > /dev/tcp/127.0.0.1/49134) 2>/dev/null; then |
| echo "[entrypoint] iii engine up (pid=$III_PID)" |
| break |
| fi |
| if ! kill -0 "$III_PID" 2>/dev/null; then |
| echo "[entrypoint] FATAL: iii engine died, log tail:" >&2 |
| tail -50 "$LOG_DIR/iii.log" >&2 |
| exit 1 |
| fi |
| sleep 1 |
| done |
|
|
| |
| echo "[entrypoint] starting browser-worker" |
| ( |
| cd /opt/evetool/workers/browser |
| |
| uv sync 2>>"$LOG_DIR/browser-worker.log" |
| exec uv run python worker.py |
| ) >"$LOG_DIR/browser-worker.log" 2>&1 & |
| BW_PID=$! |
| echo "[entrypoint] browser-worker pid=$BW_PID" |
|
|
| |
| echo "[entrypoint] starting mcp-gateway" |
| ( |
| cd /opt/evetool/mcp-gateway |
| uv sync 2>>"$LOG_DIR/mcp-gateway.log" |
| exec uv run python server.py |
| ) >"$LOG_DIR/mcp-gateway.log" 2>&1 & |
| GW_PID=$! |
| echo "[entrypoint] mcp-gateway pid=$GW_PID" |
|
|
| |
| cleanup() { |
| echo "[entrypoint] shutting down (iii=$III_PID browser=$BW_PID gateway=$GW_PID)" |
| kill -TERM "$GW_PID" 2>/dev/null || true |
| kill -TERM "$BW_PID" 2>/dev/null || true |
| kill -TERM "$III_PID" 2>/dev/null || true |
| wait 2>/dev/null || true |
| exit 0 |
| } |
| trap cleanup SIGTERM SIGINT |
|
|
| |
| wait -n "$III_PID" "$BW_PID" "$GW_PID" |
| EXIT_CODE=$? |
| echo "[entrypoint] one of (iii/browser/gateway) exited with $EXIT_CODE, killing others" >&2 |
| cleanup |
| exit 1 |
|
|