From 70a2910b74f26539f0d2f87343477ffc8adfbbfd Mon Sep 17 00:00:00 2001 From: Chris Oloff Date: Wed, 14 Jan 2026 14:51:39 +0200 Subject: [PATCH] add run.sh for easy launching, also waits for port to be open before launching browser --- run.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 run.sh diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..f8154e6 --- /dev/null +++ b/run.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +echo "Starting the application..." + +PORT=5050 + +cleanup() { + echo "Stopping the application..." + pkill -f "panel serve main.py" +} + +trap cleanup EXIT + +poetry run panel serve main.py --port $PORT & + +# if 'nc' is available, use it to check if the port is open +if ! command -v nc &> /dev/null +then + echo "'nc' command could not be found, please install it for better port checking." + sleep 2 +else + # wait until port is open + while ! nc -z localhost $PORT; do + sleep 0.5 + done +fi + +poetry run python -m webbrowser http://localhost:$PORT + +# wait until user kills the process (by hitting ctrl+c or otherwise) +wait