#!/bin/bash # Unified startup script for Lyra (Relay + Cortex) set -e echo "🚀 Starting Lyra unified container..." # Start Cortex (Python/FastAPI) in the background echo "📡 Starting Cortex on port 7081..." cd /app/cortex uvicorn main:app --host 0.0.0.0 --port 7081 & CORTEX_PID=$! # Wait for Cortex to be ready echo "⏳ Waiting for Cortex to be ready..." for i in {1..30}; do if curl -sf http://localhost:7081/_health > /dev/null 2>&1; then echo "✅ Cortex is ready!" break fi if [ $i -eq 30 ]; then echo "❌ Cortex failed to start within 30 seconds" exit 1 fi sleep 1 done # Start Relay (Node.js/Express) in the foreground echo "🔌 Starting Relay on port 7078..." cd /app/relay exec node server.js # Note: We exec the last process so signals get forwarded properly # If Relay dies, the container stops. If Cortex dies, Relay will fail too.