File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3232 instead of silently attaching a stale CLI to the same config home.
3333 Label-less images keep the bare agent name (#420 )
3434- Traced sessions publish the cctrace live UI to the host loopback:
35- free port probed from 9317, ` Trace UI: http://localhost :<port> ` printed
35+ free port probed from 9317, ` Trace UI: http://127.0.0.1 :<port> ` printed
3636 before the TUI starts, and the host browser opens the moment the UI
3737 answers (poll-then-open; ` DEVA_TRACE_OPEN=0 ` disables). Attaching to a
3838 persistent container created without the port warns instead (#425 )
Original file line number Diff line number Diff line change @@ -233,15 +233,23 @@ DEVA_TRACE_UI_URL=""
233233setup_trace_ui_port () {
234234 local port=9317
235235 local tries=0
236+ local free_port=" "
236237 while [ " $tries " -lt 12 ]; do
237238 if ! (exec 3<> " /dev/tcp/127.0.0.1/$port " ) 2> /dev/null; then
239+ free_port=" $port "
238240 break
239241 fi
240242 port=$(( port + 1 ))
241243 tries=$(( tries + 1 ))
242244 done
243- DOCKER_ARGS+=(" -p" " 127.0.0.1:${port} :9317" )
244- DEVA_TRACE_UI_URL=" http://localhost:${port} "
245+
246+ if [ -z " $free_port " ]; then
247+ echo " warning: no free host port in 9317-9328; trace UI will not be reachable from the host" >&2
248+ return 0
249+ fi
250+
251+ DOCKER_ARGS+=(" -p" " 127.0.0.1:${free_port} :9317" )
252+ DEVA_TRACE_UI_URL=" http://127.0.0.1:${free_port} "
245253}
246254
247255# Print the trace UI URL before the TUI takes the screen, and open the host
@@ -253,13 +261,15 @@ announce_trace_ui() {
253261
254262 local url=" $DEVA_TRACE_UI_URL "
255263 if [ " ${1:- new} " = " existing" ]; then
264+ # docker port exits non-zero for unpublished mappings; under
265+ # set -euo pipefail that must not kill the launch.
256266 local mapping
257- mapping=$( docker port " $CONTAINER_NAME " 9317/tcp 2> /dev/null | head -1)
267+ mapping=$( docker port " $CONTAINER_NAME " 9317/tcp 2> /dev/null | head -1 || true )
258268 if [ -z " $mapping " ]; then
259269 echo " warning: trace UI not reachable — container was created without the trace port; recreate it (deva rm) or use --rm" >&2
260270 return 0
261271 fi
262- url=" http://localhost :${mapping##*: } "
272+ url=" http://127.0.0.1 :${mapping##*: } "
263273 fi
264274 [ -n " $url " ] || return 0
265275
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ published to the host loopback. deva prints the URL before the TUI takes
186186the screen and opens your host browser the moment the UI answers:
187187
188188``` text
189- Trace UI: http://localhost:9317 (live once the agent starts)
189+ Trace UI: http://127.0.0.1:<port> (live once the agent starts)
190190```
191191
192192Set ` DEVA_TRACE_OPEN=0 ` to keep the banner but skip the auto-open.
You can’t perform that action at this time.
0 commit comments