Source identity
| Field | Recorded value |
|---|---|
| Source type | GitHub source |
| Original record | Janady13/missionmatch / ops/m4/gateway-backend.sh |
| Date | Not specified in source |
| Repository | Janady13/missionmatch |
| Revision | 720d47fae476b0d38477ae4401697d372b1ea2bc |
| Branch | feature/opportunity-to-outcome |
| Path or archive member | ops/m4/gateway-backend.sh |
| Original SHA-256 | d61acdd359683b815472fa59467292134d07823744464a11676a966209135278 |
| Git blob SHA | 0dd471d20462f70c29711f99debaa4fdd0e78a34 |
| Reading-copy SHA-256 | d61acdd359683b815472fa59467292134d07823744464a11676a966209135278 |
Every recorded occurrence
These 2 records contain identical original source bytes. Their paths and revisions remain part of the archive.
| Original record | Branch or archive | Revision / identifier | Original location |
|---|---|---|---|
| Janady13/missionmatch / ops/m4/gateway-backend.sh | feature/opportunity-to-outcome | 720d47fae476b0d38477ae4401697d372b1ea2bc | Open original |
| Janady13/missionmatch / ops/m4/gateway-backend.sh | feature/aioe-upgrade | 2178e7298d0e5d9af83afa12402fd587f0ba6ed8 | Open original |
Recovered source transcript
Download complete source text ↓56 lines · 2.6 KB
#!/bin/bash
# Flip the missionMATCH generation runtime the MEGAMIND gateway proxies, then verify it.
#
# gateway-backend.sh ollama the local Ollama binary (default, no Python, Metal accelerated)
# gateway-backend.sh mlx the external MLX server on 8081 (Apple Silicon, fastest on an M chip)
# gateway-backend.sh megamind the MEGAMIND reasoning brain on 9999 (answers from its own learned corpus)
#
# Embeddings ALWAYS stay on Ollama's bge model so the stored vectors and the boot vector gate keep matching;
# only generation is selectable. The running mm-api reads the gateway per request, so a flip is picked up with
# no mm-api redeploy. If the selected backend fails at request time the gateway falls back to Ollama.
set -u
BACKEND=${1:-ollama}
case "$BACKEND" in
ollama|mlx|megamind) ;;
*) echo "usage: $0 ollama|mlx|megamind"; exit 2 ;;
esac
# When flipping to MLX, make sure a known good small MLX server is up on 8081 first (a 4 bit 3B model that is
# fast on an M chip and leaves room for the Ollama faithfulness model in 16GB). If it is not running, start it;
# the gateway's ollama fallback covers requests while the model loads.
if [ "$BACKEND" = "mlx" ]; then
MLXBIN="$HOME/mlx-train-venv/bin/mlx_lm.server"
MLXMODEL=mlx-community/Qwen2.5-3B-Instruct-4bit
if pgrep -f "mlx_lm.server.*--port 8081" >/dev/null 2>&1; then
echo "mlx server already up on 8081"
elif [ -x "$MLXBIN" ]; then
echo "starting mlx server ($MLXMODEL) on 8081"
nohup "$MLXBIN" --model "$MLXMODEL" --host 0.0.0.0 --port 8081 > "$HOME/mlx-server.log" 2>&1 </dev/null &
sleep 6
else
echo "mlx server binary $MLXBIN missing; the mlx backend will fall back to ollama"
fi
fi
SECRETS_FILE="${MEGAMIND_SECRETS_FILE:-$HOME/.megamind-secrets.env}"
if [ ! -f "$SECRETS_FILE" ]; then
echo "missing $SECRETS_FILE (needs MEGAMIND_GATEWAY_TOKEN=..., chmod 600); refusing to start an open gateway"
exit 1
fi
pkill -f "megamind-gateway" 2>/dev/null
sleep 1
# No MEGAMIND_ADDR: the gateway binds the Tailscale interface by itself (loopback when none is up).
MEGAMIND_SECRETS_FILE="$SECRETS_FILE" MEGAMIND_GENERATE_BACKEND="$BACKEND" \
nohup "$HOME/megamind-gateway" > "$HOME/megamind-gateway.log" 2>&1 </dev/null &
sleep 2
TSIP=$(/Applications/Tailscale.app/Contents/MacOS/Tailscale ip -4 2>/dev/null || tailscale ip -4 2>/dev/null || echo 127.0.0.1)
if ! curl -fsS -m 5 "http://$TSIP:8090/healthz" >/dev/null 2>&1; then
echo "gateway did not come up on 8090, check $HOME/megamind-gateway.log"
exit 1
fi
echo "gateway restarted with generation backend=$BACKEND"
head -1 "$HOME/megamind-gateway.log"