fix(scripts): auto-switch dev.port when it's already in use#2867
Open
hongwei1 wants to merge 1 commit into
Open
fix(scripts): auto-switch dev.port when it's already in use#2867hongwei1 wants to merge 1 commit into
hongwei1 wants to merge 1 commit into
Conversation
flushall_build_and_run.sh and flushall_fast_build_and_run.sh always started the HTTP4S server on the configured dev.port (default 8080). If that port was already bound by another local process (e.g. another OBP-API instance), the new server failed to bind or the caller had no way to know a fallback was needed. Both scripts now probe the port before starting the server and, if busy, walk forward to the next free port in a 50-port range, exporting it via OBP_DEV_PORT (APIUtil.getPropsValue checks env vars before props, so this requires no props-file change) and printing "PORT: <n>" alongside the existing "PID: <n>" line. Also fixes a hang in flushall_build_and_run.sh's background mode: it launched java with `> >(tee "$RUNTIME_LOG") 2>&1`, a process substitution whose inner tee inherits the script's own stdout fd. When this script is invoked from a caller that captures its output via command substitution piped through tee (e.g. `out=$(./flushall_build_and_run.sh --background 2>&1 | tee /dev/stderr)`, the pattern smoke_test.sh uses), that inherited fd keeps the caller's pipe open for as long as the server runs, so the command substitution never returns even though the meaningful output already printed. Switched to a plain file redirect (matching flushall_fast_build_and_run.sh, which never had this problem), so the script's own file descriptors close cleanly on exit regardless of the backgrounded server's lifetime.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
flushall_build_and_run.shandflushall_fast_build_and_run.shnow probedev.port(default 8080) before starting the server; if it's already bound, they walk forward to the next free port in a 50-port range and export it viaOBP_DEV_PORT(no props-file change needed, sinceAPIUtil.getPropsValuechecks env vars before props). Both scripts printPORT: <n>alongside the existingPID: <n>line.flushall_build_and_run.sh's background mode: it launched the server with> >(tee "$RUNTIME_LOG") 2>&1, a process substitution whose innerteeinherits the script's own stdout fd. When a caller captures this script's output via$(... | tee ...)(the pattern the localobp-api-testsmoke-test skill uses), that inherited fd keeps the caller's pipe open for as long as the server runs, so the command substitution never returns even though the meaningful output already printed. Switched to a plain file redirect, matchingflushall_fast_build_and_run.sh(which never had this problem).Test plan
/rooton the new portout=$(./flushall_build_and_run.sh --background 2>&1 | tee /dev/stderr)pattern now returns promptly after printing PID/PORTobp-api-test6-step smoke test end-to-end (test suite → build+run → get root → kill → fast-rebuild+run → get root) with port 8080 occupied — all 6 steps passed