#!/bin/bash # ╔══════════════════════════════════════════════════════════╗ # ║ 🚀 ONE-CLICK TURBOCHARGE FOR QWEN2GOLEM 🚀 ║ # ║ Press this button to make EVERYTHING LIGHTNING FAST! ║ # ╚══════════════════════════════════════════════════════════╝ echo "" echo " ⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡" echo " 🔥 INITIATING ULTIMATE TURBOCHARGE SEQUENCE 🔥" echo " ⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡⚡" echo "" echo " Target System: RTX 3050 6GB + i5 CPU + 16GB RAM" echo " Mission: ACHIEVE LIGHTNING SPEED WITHOUT COMPROMISE!" echo "" # Countdown for dramatic effect echo " Launching in..." for i in 3 2 1; do echo " $i..." sleep 1 done echo " 🚀 BLAST OFF!" echo "" # Check if we need to install first if [ ! -f "golem_optimizer.py" ] || [ ! -f "voice_optimizer.py" ]; then echo "⚠️ Optimization files not found. Running installer first..." if [ -f "install_optimizations.sh" ]; then chmod +x install_optimizations.sh ./install_optimizations.sh else echo "❌ Installation script not found! Please ensure all files are present." exit 1 fi fi # Start Redis if not running echo "🗄️ Checking Redis cache..." if ! pgrep -x "redis-server" > /dev/null; then echo " Starting Redis server (user mode)..." redis-server --daemonize yes || true fi # Clear GPU cache echo "🎮 Preparing GPU..." python -c " import torch if torch.cuda.is_available(): torch.cuda.empty_cache() torch.cuda.synchronize() print(' ✅ GPU cache cleared') else: print(' ⚠️ GPU not available') " # Refresh Gemini keys echo "🔑 Refreshing API keys..." if [ -f "refresh_gemini_keys.sh" ]; then ./refresh_gemini_keys.sh > /dev/null 2>&1 & echo " ✅ Key refresh running in background" fi # Run the main optimizer echo "" echo "⚡ APPLYING OPTIMIZATIONS..." python golem_optimizer.py # Start the optimized server echo "" echo "🚀 STARTING TURBOCHARGED SERVER..." echo "" # Set environment variables for maximum performance export CUDA_VISIBLE_DEVICES=0 export PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512 export CUDA_LAUNCH_BLOCKING=0 export TORCH_CUDNN_V8_API_ENABLED=1 export TF32_ENABLE=1 export CUBLAS_WORKSPACE_CONFIG=:4096:8 # Check if gunicorn is available if command -v gunicorn &> /dev/null; then echo "✅ Starting with Gunicorn (optimal performance)..." gunicorn home.chezy.golem_flask_server:app \ --workers 4 \ --worker-class gevent \ --worker-connections 1000 \ --bind 0.0.0.0:5000 \ --timeout 30 \ --keep-alive 5 \ --max-requests 10000 \ --max-requests-jitter 1000 \ --log-level info else echo "⚠️ Gunicorn not found, starting with Flask development server..." echo " (Install gunicorn and gevent for better performance)" # Free port 5000 if busy if lsof -i :5000 -t >/dev/null 2>&1; then echo " Port 5000 busy; stopping old process..." kill -9 $(lsof -i :5000 -t) || true sleep 1 fi cd home/chezy/ python golem_flask_server.py fi