From 2b025673d691194b3e7d9e05bd4afec46dece999 Mon Sep 17 00:00:00 2001 From: ajaysi Date: Mon, 6 Apr 2026 07:05:01 +0530 Subject: [PATCH] Use start_alwrity_backend.py via Procfile, single requirements.txt --- backend/Procfile | 4 ++- backend/gunicorn_config.py | 3 ++- backend/render-build.sh | 51 ++++++++++++++++++++++++++++++++------ 3 files changed, 49 insertions(+), 9 deletions(-) diff --git a/backend/Procfile b/backend/Procfile index 3f32b904..993f7c66 100644 --- a/backend/Procfile +++ b/backend/Procfile @@ -1 +1,3 @@ -web: gunicorn -c gunicorn_config.py app:app +# Use start_alwrity_backend.py for deployment +# This script handles all bootstrap logic and starts uvicorn +web: python start_alwrity_backend.py diff --git a/backend/gunicorn_config.py b/backend/gunicorn_config.py index 78c67781..3450348b 100644 --- a/backend/gunicorn_config.py +++ b/backend/gunicorn_config.py @@ -26,9 +26,10 @@ errorlog = "-" loglevel = os.getenv("LOG_LEVEL", "info").lower() # Don't preload - bind to port FIRST, then load worker -# This fixes "No open ports detected" on Render preload_app = False +# Use the startup script that handles all the logic +factory = False # app:app is not a factory, it's the app object def on_starting(server): """Called just before the master process is initialized.""" diff --git a/backend/render-build.sh b/backend/render-build.sh index d4cbfb3c..28936222 100644 --- a/backend/render-build.sh +++ b/backend/render-build.sh @@ -3,18 +3,55 @@ set -euo pipefail python -m pip install --upgrade pip setuptools wheel -# Check if podcast-only mode is enabled - skip heavy ML models if so +# Check if podcast-only mode is enabled ENABLED_FEATURES="${ALWRITY_ENABLED_FEATURES:-all}" -IS_PODCAST_ONLY=false if [[ "$ENABLED_FEATURES" == "podcast" ]]; then - IS_PODCAST_ONLY=true - echo "🔊 Podcast-only mode detected - using minimal requirements" - python -m pip install --retries 10 --timeout 120 -r requirements-podcast.txt + echo "🔊 Podcast-only mode - installing minimal dependencies" + # Create minimal requirements on-the-fly + cat > requirements_min.txt << 'EOF' +fastapi>=0.115.14 +starlette>=0.40.0,<0.47.0 +sse-starlette<3.0.0 +uvicorn>=0.24.0 +uvicorn[standard]>=0.24.0 +python-multipart>=0.0.6 +python-dotenv>=1.0.0 +loguru>=0.7.2 +tenacity>=8.2.3 +pydantic>=2.5.2,<3.0.0 +typing-extensions>=4.8.0 +PyJWT>=2.8.0 +cryptography>=41.0.0 +fastapi-clerk-auth>=0.0.7 +sqlalchemy>=2.0.25 +stripe>=8.0.0 +httpx>=0.27.2,<0.28.0 +openai>=1.3.0 +google-genai>=1.0.0 +gtts>=2.4.0 +pyttsx3>=2.90 +markdown>=3.5.0 +pandas>=2.0.0 +numpy>=1.24.0 +Pillow>=10.0.0 +huggingface_hub>=1.1.4 +moviepy==2.1.2 +imageio>=2.31.0 +imageio-ffmpeg>=0.4.9 +pytest>=7.4.0 +pytest-asyncio>=0.21.0 +apscheduler>=3.10.0 +redis>=5.0.0 +schedule>=1.2.0 +EOF + python -m pip install --retries 10 --timeout 120 -r requirements_min.txt else - echo "📦 Full mode - using all requirements" + echo "📦 Full mode - installing all dependencies" python -m pip install --retries 10 --timeout 120 -r requirements.txt - # Download required NLTK and spaCy models during build phase (skip for podcast-only) + # Download spaCy/NLTK models for full mode python -m spacy download en_core_web_sm python -m nltk.downloader punkt_tab stopwords averaged_perceptron_tagger fi + +echo "✅ Build dependencies installed"