agent-loop / start.sh
arudradey's picture
Add robust entrypoint start.sh to prevent port collision
1ad9716 verified
Raw History Blame Contribute Delete
509 Bytes
#!/bin/bash
set -e
# Gracefully wait if port 7860 is momentarily occupied by a previous process
for i in {1..10}; do
if ! python3 -c "import socket; s = socket.socket(); s.bind(('0.0.0.0', 7860)); s.close()" 2>/dev/null; then
echo "[start.sh] Port 7860 busy, waiting for release (attempt $i/10)..."
fuser -k 7860/tcp 2>/dev/null || true
sleep 1
else
break
fi
done
echo "[start.sh] Port 7860 is free. Starting Uvicorn on 0.0.0.0:7860..."
exec uvicorn app:app --host 0.0.0.0 --port 7860