Spaces:
Paused
Paused
Download scripts/run_prod.sh from 3SCError404/nexus: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scripts/run_prod.sh
- Command line
-
hf download hf://spaces/3SCError404/nexus/scripts/run_prod.sh
-
curl -L -o run_prod.sh https://huggingface.co/spaces/3SCError404/nexus/resolve/main/scripts/run_prod.sh
1.34 kB
| # Production Entrypoint for Hugging Face Spaces | |
| # This script runs both the FastAPI API and the Arq Worker in the same container. | |
| echo "--- NEXUS PRODUCTION BOOTSTRAP ---" | |
| # Start Local Redis for Caching (Ephemeral Sidecar) | |
| echo "[0/3] Starting Local Redis..." | |
| redis-server --daemonize yes --port 6379 | |
| # wait for redis to be ready | |
| RETRIES=5 | |
| until redis-cli -p 6379 ping > /dev/null 2>&1 || [ $RETRIES -eq 0 ]; do | |
| echo "Waiting for Redis to start... ($RETRIES retries left)" | |
| sleep 1 | |
| RETRIES=$((RETRIES-1)) | |
| done | |
| if ! redis-cli -p 6379 ping > /dev/null 2>&1; then | |
| echo "[⚠️ WARNING] Local Redis failed to start. Backend may use fallback cache." | |
| fi | |
| # Start Arq Worker in the background | |
| echo "[1/3] Starting Nexus AI Worker (arq)..." | |
| # Persistence Mapping: Use the /data mount if available | |
| if [ -d "/data" ]; then | |
| echo "--- PERSISTENT STORAGE DETECTED (/data) ---" | |
| mkdir -p /data/uploads /data/logs | |
| export UPLOAD_DIR="/data/uploads" | |
| export LOG_DIR="/data/logs" | |
| fi | |
| # Note: Using the arq CLI directly for the sidecar | |
| arq nexus_worker.WorkerSettings & | |
| # Start FastAPI API in the foreground | |
| APP_PORT=${PORT:-7860} | |
| echo "[2/2] Starting Nexus Master API (uvicorn) on port ${APP_PORT}..." | |
| uvicorn main:app --host 0.0.0.0 --port ${APP_PORT} --log-level info | |
| # Wait for all processes to exit | |
| wait -n | |
| exit $? | |