From 969e870f8e685664d4341b8ece0ef8da538f09d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Nov 2025 11:58:48 -0800 Subject: [PATCH] ... --- ebook2audiobook.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/ebook2audiobook.sh b/ebook2audiobook.sh index ae61f2c9..80a039a0 100755 --- a/ebook2audiobook.sh +++ b/ebook2audiobook.sh @@ -432,10 +432,23 @@ cat > "$MACOS/$APP_NAME" << EOF host=127.0.0.1 port=7860 url="http://\$host:\$port/" - until curl -fs \$url >/dev/null 2>&1; do - sleep 1 - done - open \$url + timeout=30 + start_time=\$(date +%s) + + echo "Waiting for \$url ..." + + while ! nc -z "\$host" "\$port" >/dev/null 2>&1; do + sleep 1 + elapsed=\$(( \$(date +%s) - \$start_time )) + if [ "\$elapsed" -ge "\$timeout" ]; then + echo "Timeout after \${timeout}s: \${url} not responding" + exit 0 + fi + done + + sleep 1 + open "\$url" + exit 0 ) & # TODO: replace when log available in gradio with