synq-core-os/scripts/launch-synq-core-app.sh
cavalier8030 deb2480655 fix(stream): launch scripts, Odoo mock bridge, and Vite base path for production builds
- Add launch scripts for synq-core runtime and synq-stream desktop app
- Create Odoo mock bridge server for local development
- Fix Vite base path to relative (./) for Tauri embedded assets
- Add desktop launcher shortcuts
- Configure env for available Ollama models and mock Odoo bridge
2026-05-07 13:42:32 -07:00

102 lines
4.1 KiB
Bash
Executable file

#!/bin/bash
set -e
cd "$(dirname "$0")/.."
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ Synq Core App Launcher ║"
echo "║ (synq-stream — desktop runtime) ║"
echo "╚═══════════════════════════════════════════════════════╝"
# ─── 1. PostgreSQL ───
if ! docker ps | grep -q synq-core-db; then
echo "[1/7] Starting PostgreSQL (pgvector)..."
docker start synq-core-db || docker compose up -d postgres
sleep 3
else
echo "[1/7] PostgreSQL already running"
fi
# ─── 2. Ollama ───
if ! curl -s http://localhost:11434/api/tags > /dev/null; then
echo "[2/7] Starting Ollama..."
ollama serve &
sleep 5
else
echo "[2/7] Ollama already running"
fi
# ─── 3. Odoo Mock Bridge ───
if ! curl -s http://localhost:8019/synq/desktop/v1/authenticate -X POST \
-H "X-Synq-Desktop-Token: demo" -H "X-Synq-Desktop-Secret: demo" \
-d '{"jsonrpc":"2.0","method":"call","params":{},"id":1}' > /dev/null; then
echo "[3/7] Starting Odoo Mock Bridge on :8019..."
python3 scripts/odoo_mock_bridge.py > /tmp/odoo_mock.log 2>&1 &
sleep 1
else
echo "[3/7] Odoo Mock Bridge already running"
fi
# ─── 4. Build Rust binaries ───
echo "[4/7] Building Rust binaries..."
cargo build --release --bin synq-cli --bin synq-intel-server --bin synq-shell 2>&1 | tail -3
cargo build --release -p stream 2>&1 | tail -3
# Ensure synq-stream symlink exists
if [ ! -f target/release/synq-stream ]; then
ln -sf $(pwd)/target/release/stream $(pwd)/target/release/synq-stream
fi
# ─── 5. Start Intel Server ───
if ! curl -s http://localhost:3001/api/health > /dev/null; then
echo "[5/7] Starting Synq Intel Server on :3001..."
./target/release/synq-intel-server > /tmp/synq-intel.log 2>&1 &
sleep 2
else
echo "[5/7] Synq Intel Server already running"
fi
# ─── 6. Smoke tests ───
echo "[6/7] Running smoke tests..."
echo " → PostgreSQL: $(docker exec synq-core-db pg_isready -U synq -d synq_core 2>/dev/null | grep -q 'accepting connections' && echo 'OK' || echo 'FAIL')"
echo " → Odoo Bridge: $(curl -s http://localhost:8019/synq/desktop/v1/authenticate -X POST -H 'Content-Type: application/json' -H 'X-Synq-Desktop-Token: demo' -H 'X-Synq-Desktop-Secret: demo' -d '{"jsonrpc":"2.0","method":"call","params":{},"id":1}' | python3 -c "import sys,json; d=json.load(sys.stdin); print('OK' if d.get('result',{}).get('status')=='ok' else 'FAIL')" 2>/dev/null)"
echo " → Ollama: $(curl -s http://localhost:11434/api/tags | python3 -c "import sys,json; d=json.load(sys.stdin); print('OK' if len(d.get('models',[]))>0 else 'FAIL')" 2>/dev/null)"
echo " → Intel Server: $(curl -s http://localhost:3001/api/health 2>/dev/null || echo 'FAIL')"
# ─── 7. Launch Synq Stream ───
echo "[7/7] Launching Synq Stream desktop app..."
echo ""
echo " The app will open fullscreen."
echo " To exit: use the in-app exit button or press Alt+F4."
echo ""
if [ -n "$DISPLAY" ]; then
nohup ./target/release/synq-stream > /tmp/synq-stream.log 2>&1 &
APP_PID=$!
disown $APP_PID 2>/dev/null || true
echo " App PID: $APP_PID"
sleep 2
if ps -p $APP_PID > /dev/null 2>&1; then
echo " ✅ Synq Stream is running."
else
echo " ⚠️ Synq Stream exited immediately. Check /tmp/synq-stream.log"
fi
else
echo " ⚠️ No DISPLAY detected. Cannot launch GUI app in this terminal."
echo " Please run this script from a desktop terminal session."
fi
echo ""
echo "✅ Synq Core App launch complete!"
echo ""
echo "Backends:"
echo " • PostgreSQL : localhost:5433"
echo " • Ollama : localhost:11434"
echo " • Odoo Bridge : localhost:8019"
echo " • Intel Server : localhost:3001"
echo ""
# Keep terminal open if launched by double-click
if [[ -t 0 ]]; then
read -p "Press Enter to exit..."
fi