接入 LinuxCNC TP 运行反馈
This commit is contained in:
36
web-rtcp-5axis-sim-plan/open-local.sh
Executable file
36
web-rtcp-5axis-sim-plan/open-local.sh
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
APP_DIR="/home/cnc/桌面/cnc_wams/web-rtcp-5axis-sim-plan/app/dist"
|
||||
PORT="8092"
|
||||
URL="http://127.0.0.1:${PORT}/"
|
||||
LOG_DIR="${HOME}/.cache/web-rtcp-5axis-sim"
|
||||
LOG_FILE="${LOG_DIR}/local-server.log"
|
||||
|
||||
mkdir -p "$LOG_DIR"
|
||||
|
||||
is_serving() {
|
||||
curl -fsS --max-time 1 "$URL" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
if ! is_serving; then
|
||||
nohup python3 -m http.server "$PORT" --bind 127.0.0.1 --directory "$APP_DIR" >"$LOG_FILE" 2>&1 &
|
||||
for _ in $(seq 1 40); do
|
||||
if is_serving; then
|
||||
break
|
||||
fi
|
||||
sleep 0.1
|
||||
done
|
||||
fi
|
||||
|
||||
if command -v google-chrome-stable >/dev/null 2>&1; then
|
||||
exec google-chrome-stable --new-window "$URL"
|
||||
elif command -v google-chrome >/dev/null 2>&1; then
|
||||
exec google-chrome --new-window "$URL"
|
||||
elif command -v chromium >/dev/null 2>&1; then
|
||||
exec chromium --new-window "$URL"
|
||||
elif command -v chromium-browser >/dev/null 2>&1; then
|
||||
exec chromium-browser --new-window "$URL"
|
||||
else
|
||||
exec xdg-open "$URL"
|
||||
fi
|
||||
Reference in New Issue
Block a user