refactor(445): drop e2e-ui.sh's port pre-flight, now owned by e2e-local.sh (#586/#598)
main's #598 added a port pre-flight to scripts/e2e-local.sh while this branch was in review, and theirs is strictly better than the one I had here: - it probes BOTH bound ports. The app binds a SECOND (streaming) listener that defaults to 8409 regardless of ETV_UI_PORT, so my single-port check could certify a port free while the run still died binding 8409. That also means this PR's CI step (ETV_UI_PORT=8410) was only working because the curl step's server had already been killed — #598's fix, defaulting ETV_STREAMING_PORT to the given port, is what makes it correct rather than lucky. A real latent bug in my work, surfaced by their change. - it REPORTS rather than reaps, which is the #586 rule. Keeping mine would leave two divergent port checks on the same concern. Also records the app's SINGLE-INSTANCE guard, which is independent of ports: a stray instance blocks a run whatever port you choose, so 'pick another port' is not a workaround. Kill the leftover BY PID (#586). Refs #445 #586
This commit is contained in:
+7
-16
@@ -61,23 +61,14 @@ if ! (cd "$REPO_ROOT/web" && node -e "require('@playwright/test').chromium.launc
|
||||
fi
|
||||
rm -f "$PW_PROBE_ERR"
|
||||
|
||||
# Pre-flight: fail fast and clearly if the port is already taken. Otherwise the symptom is
|
||||
# e2e-local.sh's 120s readiness timeout, which reads like a broken build rather than "something else
|
||||
# is already listening" — a real hazard when several sessions share this machine.
|
||||
# No port pre-flight here: `scripts/e2e-local.sh` owns that since ersatztv#586/#598, and its version
|
||||
# is strictly better — it probes BOTH bound ports (the app binds a second, streaming listener that
|
||||
# otherwise defaults to 8409 regardless of ETV_UI_PORT) and it REPORTS rather than reaps. Duplicating
|
||||
# it here would mean two divergent checks with different messages on the same concern.
|
||||
#
|
||||
# `-sTCP:LISTEN` matters: a bare `lsof -ti :PORT` also matches outbound/ESTABLISHED/TIME_WAIT
|
||||
# sockets touching that port number, which would abort on a false positive.
|
||||
#
|
||||
# This is a LOCAL-developer guard. The CI toolchain image ships no `lsof`, so the check silently
|
||||
# no-ops there — acceptable, because each CI job gets a fresh container where nothing else is bound.
|
||||
if command -v lsof >/dev/null 2>&1 && [ -n "$(lsof -ti :"$PORT" -sTCP:LISTEN 2>/dev/null || true)" ]; then
|
||||
echo "error: port $PORT already has a listener: PID(s) $(lsof -ti :"$PORT" -sTCP:LISTEN | tr '\n' ' ')" >&2
|
||||
echo " Another instance (possibly another session's) is listening. Stop it, or re-run with" >&2
|
||||
echo " a free port, e.g. ETV_UI_PORT=8419 scripts/e2e-ui.sh" >&2
|
||||
echo " (8409/8410 are prod + ersatztv-test on jazz; 8411 is scripts/security-scan.sh.)" >&2
|
||||
echo " Do NOT blanket-kill 'dotnet ErsatzTV.dll' — that can reap another session's server." >&2
|
||||
exit 1
|
||||
fi
|
||||
# Note the app also enforces a SINGLE-INSTANCE guard of its own ("Another instance of ErsatztTV is
|
||||
# already running"), independent of ports — so a stray instance anywhere blocks a run regardless of
|
||||
# which port you pick. Kill the leftover BY PID; never `pkill -f dotnet ErsatzTV.dll` (#586).
|
||||
|
||||
# --- Server lifecycle -------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user