forked from NVlabs/trajdata
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_webui.sh
More file actions
executable file
·55 lines (50 loc) · 1.16 KB
/
run_webui.sh
File metadata and controls
executable file
·55 lines (50 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env bash
# Launch, stop or restart the trajdata Web UI
set -e
cd "$(dirname "$0")"
PORT=5006
COMMAND="run"
EXTRA_ARGS=""
while [[ $# -gt 0 ]]; do
case $1 in
stop) COMMAND="stop"; shift ;;
restart) COMMAND="restart"; shift ;;
--port) PORT="$2"; shift 2 ;;
--port=*) PORT="${1#*=}"; shift ;;
--no-browser) EXTRA_ARGS="$EXTRA_ARGS --no-browser"; shift ;;
*) shift ;;
esac
done
function stop_server() {
PID=$(lsof -ti :$PORT || true)
if [ -n "$PID" ]; then
echo "Stopping server on port $PORT (PID: $PID)..."
kill -9 $PID 2>/dev/null || true
sleep 1
else
echo "No server running on port $PORT."
fi
}
function run_server() {
# Auto-kill if port is busy before running
PID=$(lsof -ti :$PORT || true)
if [ -n "$PID" ]; then
echo "Force-closing existing process on port $PORT..."
kill -9 $PID 2>/dev/null || true
sleep 0.5
fi
echo "Launching trajdata Web UI at http://localhost:$PORT/..."
exec .venv/bin/python trajdata_webui/main.py --port "$PORT" $EXTRA_ARGS
}
case $COMMAND in
stop)
stop_server
;;
restart)
stop_server
run_server
;;
run)
run_server
;;
esac