Commit ·
e10bf6b
1
Parent(s): 65b6449
fix: exit gracefully on port conflict in dev mode
Browse filesDev mode spawns CMD multiple times; duplicates that can't bind port
exit with code 0 instead of 1 so the daemon doesn't kill the app.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1234567#!/bin/bash# Entrypoint for HF Spaces dev mode compatibility.# Dev mode may spawn the CMD multiple times; kill any prior# uvicorn instance so the new one can bind the port.pkill -f "uvicorn main:app" 2>/dev/null || truesleep 0.3exec uvicorn main:app --host 0.0.0.0 --port 7860123456789101112131415#!/bin/bash# Entrypoint for HF Spaces dev mode compatibility.# Dev mode spawns CMD multiple times simultaneously on restart.# Only the first instance can bind port 7860 — the rest must exit# with code 0 so the dev mode daemon doesn't mark the app as crashed.# Run uvicorn; if it fails due to port conflict, exit cleanly.uvicorn main:app --host 0.0.0.0 --port 7860EXIT_CODE=$?if [ $EXIT_CODE -ne 0 ]; then# Check if this was a port-in-use failure (another instance already running)echo "uvicorn exited with code $EXIT_CODE, exiting gracefully."exit 0fi
backend/start.sh+13-5