#!/bin/bash set -e pkill -f "health" 2>/dev/null || true crontab -r 2>/dev/null || true echo "[boot] Writing custom nginx config..." cat > /etc/nginx/sites-available/default << 'NGX' server { listen 7860; location /ollama/ { rewrite ^/ollama/(.*) /$1 break; proxy_pass http://127.0.0.1:11434; proxy_http_version 1.1; proxy_set_header Host $host; proxy_read_timeout 600s; proxy_send_timeout 600s; } location / { proxy_pass http://127.0.0.1:8080; proxy_set_header Host $host; proxy_read_timeout 600s; proxy_send_timeout 600s; } } NGX echo "[boot] Nginx config written" echo "[boot] Starting health+chat server on :8080..." python3 /app/health_server.py & echo "[boot] Health server PID: $!" echo "[boot] Starting nginx..." nginx echo "[boot] Starting Ollama..." export OLLAMA_FLASH_ATTENTION=1 export OLLAMA_KV_CACHE_TYPE=q4_0 export OLLAMA_NUM_CTX=131072 OLLAMA_HOST=127.0.0.1 OLLAMA_NUM_PARALLEL=1 OLLAMA_MAX_LOADED_MODELS=1 ollama serve & for i in $(seq 1 30); do if curl -sf http://127.0.0.1:11434/api/tags > /dev/null 2>&1; then echo "[boot] Ollama ready after ${i}s"; break fi sleep 2 done echo "[boot] Pulling IQ3_XS model for 128K context..." ollama pull hf.co/bartowski/DeepSeek-R1-Distill-Qwen-14B-GGUF:IQ3_XS & PULL_PID=$! wait $PULL_PID echo "[boot] Model ready" echo "" echo "==============================================" echo " YT Claw Chat LIVE - 14B IQ3_XS (128K)" echo "==============================================" echo "" sleep infinity