Stirling-Tools / Stirling-PDF

#1 Locally hosted web application that allows you to perform various operations on PDF files
MIT License
42.32k stars 3.36k forks source link

[Feature Request]: command flag to use the next available port #1882

Open knyipab opened 1 week ago

knyipab commented 1 week ago

Feature Description

Perhaps a --port <port_num> commandline option. And specifying --port auto will find the next available port that is larger than 8080.

Why is this feature valuable?

8080 port is way to common for web apps. I well understand that docker can do port forwarding. However, there are non-docker user, as well as OS/arch that could not quite use docker e.g. arm board and Termux. It would be really helpful if there could be a flag to find and use the next available port, which is what app like jupyterlab behave. User can simply click the link shown in terminal to open webui. User can simply click the link shown in terminal to open webui.

Now I actually use below script to detect link and start the styling-pdf when it is ready. It seems better than opening the browser before the server is even ready

url_opened=false
cd "/usr/var/lib/stirling-pdf"

exec $JAVA_HOME/bin/java --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.desktop/javax.swing=ALL-UNNAMED -jar /usr/share/stirling-pdf/stirling-pdf-0.28.3.jar "$@" | while IFS= read -r line; do
echo "$line"
if echo "$line" | grep -qE 'http://localhost:[0-9]+'; then
url=$(echo "$line" | grep -oE 'http://localhost:[0-9]+')
if [ "$url_opened" = false ]; then
-xdg-open "$url"
url_opened=true
fi
fi
done

Suggested Implementation

No response

Additional Information

No response

No Duplicate of the Feature

Akhil-2020171 commented 4 days ago

I can integrate the command line flag functionality for the port in the existing project. Please assign it to me.

sbplat commented 4 days ago

Sure, I've assigned this issue to you! If you have any questions, please feel free to ask.