#!/usr/bin/env bash set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" mkdir -p .runtime/logs if ! curl -fsS http://127.0.0.1:8080/health >/dev/null 2>&1; then echo "Starting MiniCPM4-8B..." ./scripts/start_minicpm.sh >.runtime/logs/minicpm.log 2>&1 & MODEL_PID=$! trap 'kill "$MODEL_PID" 2>/dev/null || true' EXIT INT TERM for _ in $(seq 1 180); do if curl -fsS http://127.0.0.1:8080/health >/dev/null 2>&1; then echo "MiniCPM4-8B is ready." break fi if ! kill -0 "$MODEL_PID" 2>/dev/null; then echo "MiniCPM failed to start. See .runtime/logs/minicpm.log" exit 1 fi sleep 2 done fi echo "Starting MeltMind Gradio app..." exec .venv/bin/python app.py