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 | 1e9249840a4302ec82e123b9c9cb6f75badea3e4 |
| Branch | master |
| Path or archive member | ops/m4/gateway-backend.sh |
| Original SHA-256 | a19fb06aaa488a39eec4a4e659e48025b9d2f0f8f98b90afe4eacf293cd3db0e |
| Git blob SHA | 0bdbc8bd3d3c8f0e7af39b7d9b59fbd7ef19e2ec |
| Reading-copy SHA-256 | a19fb06aaa488a39eec4a4e659e48025b9d2f0f8f98b90afe4eacf293cd3db0e |
Recovered source transcript
Download complete source text ↓48 lines · 2.1 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
pkill -f "megamind-gateway" 2>/dev/null
sleep 1
MEGAMIND_ADDR=0.0.0.0:8090 MEGAMIND_GENERATE_BACKEND="$BACKEND" \
nohup "$HOME/megamind-gateway" > "$HOME/megamind-gateway.log" 2>&1 </dev/null &
sleep 2
if ! curl -fsS -m 5 http://127.0.0.1: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"