| # 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 | |