Monorepo for Aesthetic.Computer aesthetic.computer
at main 64 lines 1.9 kB view raw
1#!/bin/bash 2# Helper script to export environment variables for benchmark 3# Source this file: source utilities/benchmark-setup-env.sh 4 5# Colors 6GREEN='\033[0;32m' 7YELLOW='\033[1;33m' 8BLUE='\033[0;36m' 9NC='\033[0m' # No Color 10 11echo -e "${BLUE}Setting up environment variables for MongoDB benchmark${NC}" 12echo "" 13 14# Try to find Atlas credentials from existing .env files 15ENV_FILE="" 16 17# Check common locations 18for file in system/.env netlify.toml .env; do 19 if [ -f "$file" ] && grep -q "MONGODB_CONNECTION_STRING" "$file" 2>/dev/null; then 20 ENV_FILE="$file" 21 break 22 fi 23done 24 25if [ -n "$ENV_FILE" ]; then 26 echo -e "${GREEN}Found credentials in: $ENV_FILE${NC}" 27 28 # Export Atlas variables 29 export MONGODB_CONNECTION_STRING=$(grep MONGODB_CONNECTION_STRING "$ENV_FILE" | cut -d '=' -f2- | tr -d '"' | tr -d "'") 30 export MONGODB_NAME=$(grep MONGODB_NAME "$ENV_FILE" | cut -d '=' -f2- | tr -d '"' | tr -d "'") 31 32 if [ -n "$MONGODB_CONNECTION_STRING" ]; then 33 echo -e "${GREEN}✅ MONGODB_CONNECTION_STRING set${NC}" 34 fi 35 36 if [ -n "$MONGODB_NAME" ]; then 37 echo -e "${GREEN}✅ MONGODB_NAME set to: $MONGODB_NAME${NC}" 38 fi 39else 40 echo -e "${YELLOW}⚠️ Could not find MONGODB_CONNECTION_STRING in .env files${NC}" 41 echo "" 42 echo "Please manually set:" 43 echo " export MONGODB_CONNECTION_STRING=\"mongodb+srv://...\"" 44 echo " export MONGODB_NAME=\"aesthetic\"" 45fi 46 47# Set silo defaults (can be overridden) 48if [ -z "$SILO_MONGODB_CONNECTION_STRING" ]; then 49 export SILO_MONGODB_CONNECTION_STRING="mongodb://silo.aesthetic.computer:27017/aesthetic" 50 echo -e "${BLUE}Using default silo connection: $SILO_MONGODB_CONNECTION_STRING${NC}" 51fi 52 53if [ -z "$SILO_MONGODB_NAME" ]; then 54 export SILO_MONGODB_NAME="aesthetic" 55fi 56 57echo "" 58echo -e "${GREEN}Environment ready!${NC}" 59echo "" 60echo "Run benchmark with:" 61echo " node utilities/benchmark-mongodb.mjs" 62echo " # or" 63echo " ./utilities/benchmark-run.sh [writes] [reads]" 64echo ""