| # Start MongoDB in the background | |
| echo "Starting MongoDB..." | |
| mkdir -p /data/db | |
| mongod --bind_ip_all --quiet & | |
| MONGOD_PID=$! | |
| # Wait for MongoDB to be ready | |
| echo "Waiting for MongoDB to start..." | |
| until nc -z localhost 27017 > /dev/null 2>&1 | |
| do | |
| sleep 1 | |
| done | |
| echo "MongoDB is ready." | |
| # Check if compiled binary exists (Docker/Production Mode) | |
| if [ -f "./morpheus-server" ]; then | |
| echo "Starting ControlMart Binary..." | |
| # Bootstrap requires .env to exist, even if empty/using env vars | |
| touch .env | |
| ./morpheus-server --no-browser | |
| else | |
| # Fallback to Source Mode (Local/Dev) | |
| echo "Starting ControlMart from Source..." | |
| cd packages/controlmart | |
| bun run run:hf | |
| fi | |