carsa_api / start.sh
athmontech's picture
Fix cache directory permissions: use /tmp instead of /app/cache
4131431
#!/bin/bash
# Don't exit on errors - we'll handle them gracefully
echo "πŸš€ Starting Carsa AI Backend..."
echo "πŸ“ Working directory: $(pwd)"
echo "🐍 Python version: $(python --version)"
# Check if main.py exists
if [ ! -f "main.py" ]; then
echo "❌ main.py not found!"
exit 1
fi
# Test import before starting server
echo "πŸ” Testing imports..."
python -c "
import sys
print('βœ… Python import test...')
try:
import fastapi
print('βœ… FastAPI imported')
import uvicorn
print('βœ… Uvicorn imported')
import torch
print('βœ… PyTorch imported')
print('🎯 All core imports successful!')
except ImportError as e:
print(f'❌ Import error: {e}')
sys.exit(1)
"
# Create cache directories with proper permissions
mkdir -p /tmp/hf_cache /tmp/numba_cache
echo "πŸ“ Cache directories ready: /tmp/hf_cache, /tmp/numba_cache"
# Set environment variables
export HF_HOME=/tmp/hf_cache
export PYTHONPATH=/app
export NUMBA_CACHE_DIR=/tmp/numba_cache
export NUMBA_DISABLE_JIT=1
echo "πŸ”§ Environment variables set"
echo "🌍 Starting server on 0.0.0.0:7860..."
python -m uvicorn main:app --host 0.0.0.0 --port 7860 --workers 1