Spaces:
Runtime error
Runtime error
| PYTHON="${HOME}/miniforge3/bin/python3" | |
| PORT_FILE="/tmp/numzoo.port" | |
| cd "$(dirname "$0")/.." | |
| # Kill the previously running instance using the saved port | |
| if [ -f "$PORT_FILE" ]; then | |
| OLD_PORT=$(cat "$PORT_FILE") | |
| OLD_PID=$(lsof -ti :$OLD_PORT 2>/dev/null) | |
| if [ -n "$OLD_PID" ]; then | |
| echo "Killing previous instance on port $OLD_PORT (pid $OLD_PID)..." | |
| kill -9 $OLD_PID 2>/dev/null | |
| sleep 1 | |
| fi | |
| rm -f "$PORT_FILE" | |
| fi | |
| $PYTHON app.py > /tmp/numzoo.log 2>&1 & | |
| echo "Starting app..." | |
| sleep 10 | |
| PORT=$(lsof -i :7860 -i :7861 -i :7862 -i :7863 -i :7864 -i :7865 2>/dev/null \ | |
| | grep LISTEN | tail -1 | grep -oE '786[0-9]') | |
| if [ -z "$PORT" ]; then | |
| echo "❌ App failed to start. Logs:" | |
| cat /tmp/numzoo.log | |
| exit 1 | |
| fi | |
| echo $PORT > "$PORT_FILE" | |
| echo "✅ App running on http://localhost:$PORT" | |