From f5db284f6f51c09c0769d75840f48514b5012245 Mon Sep 17 00:00:00 2001 From: Viet Nguyen Duc Date: Tue, 20 Oct 2026 07:00:38 +0700 Subject: [PATCH] [fix] Don't bind VIDEO_READY_PORT when video can't actually run Fixes #3271. Every browser Node image ships video_ready.py (recorder autostart) because node-base builds FROM the video image, and video-ready has always listened on port 9000 regardless of SE_RECORD_VIDEO - PR #3131 made both video-recording's and video-ready's supervisord autostart unconditional so a session could turn recording on dynamically via the se:recordVideo capability. That capability is handled entirely by video_recorder.py / video_service.py (SE_VIDEO_FILE_NAME=auto / the event-driven service); video-ready has no part in it and nothing in this repo queries its endpoint outside the Helm chart's optional, off-by-default sidecar probes. Its own handler already special-cases this: when neither SE_VIDEO_EVENT_DRIVEN nor SE_RECORD_VIDEO is true, it always answers "ready" immediately - so a container in that state gets nothing from running it, only the bound port. Compute SE_VIDEO_READY_ENABLED in Video/entry_point.sh from those two variables (or an explicit override) and have recorder.conf gate video-ready's autostart/autorestart on it. NodeBase's own defaults (SE_RECORD_VIDEO=false, SE_VIDEO_EVENT_DRIVEN=true) are unchanged by this - video-ready keeps running exactly as it does today unless a deployment also turns event-driven mode off, or sets SE_VIDEO_READY_ENABLED=false directly (the explicit opt-out the issue asked for, e.g. for network_mode: host). Verified in a real container with the actual recorder.conf and entry_point.sh under supervisord: defaults listen as today; both variables false stops it from binding the port at all; the explicit override forces it on or off regardless of the other two. Co-Authored-By: Claude Sonnet 5 --- ENV_VARIABLES.md | 2 ++ Video/entry_point.sh | 19 +++++++++++++++++++ Video/recorder.conf | 4 ++-- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/ENV_VARIABLES.md b/ENV_VARIABLES.md index 0eef2eb2b9..cbc9f3bee9 100644 --- a/ENV_VARIABLES.md +++ b/ENV_VARIABLES.md @@ -106,6 +106,8 @@ | SE_NODE_GRACEFUL_SHUTDOWN | | | | | SE_VIDEO_CONTAINER_NAME | | | | | SE_RECORD_VIDEO | false | | | +| SE_VIDEO_READY_ENABLED | (derived) | Controls whether `video_ready.py` (the video-readiness HTTP server, `VIDEO_READY_PORT`, default 9000) starts at all. Defaults to `true` whenever `SE_RECORD_VIDEO` or `SE_VIDEO_EVENT_DRIVEN` is `true` - the Node image default (`SE_VIDEO_EVENT_DRIVEN=true`) keeps it running even with `SE_RECORD_VIDEO=false`, so a session can still turn recording on via the `se:recordVideo` capability. Set this directly to `false` to force the server off (e.g. to free the port under `network_mode: host`) regardless of the other two, or `true` to force it on. | | +| VIDEO_READY_PORT | 9000 | Port `video_ready.py` listens on for readiness checks | | | SE_ENABLE_BROWSER_LEFTOVERS_CLEANUP | false | | | | SE_NODE_MAX_SESSIONS | 1 | Set the number of maximum concurrent sessions per browser Node, by default is 1 | --max-sessions | | SE_NODE_OVERRIDE_MAX_SESSIONS | false | By default is false, enable this flag for setting max session take effect in browser Node | --override-max-sessions | diff --git a/Video/entry_point.sh b/Video/entry_point.sh index 5178e2e47d..31af339c06 100755 --- a/Video/entry_point.sh +++ b/Video/entry_point.sh @@ -16,6 +16,25 @@ if [ -n "${VIRTUAL_ENV}" ]; then python3 --version fi +#============================================== +# video-ready (video_ready.py) binds VIDEO_READY_PORT (default 9000) to serve +# readiness status. It only needs to run when recording can actually happen: +# either SE_RECORD_VIDEO is on, or SE_VIDEO_EVENT_DRIVEN lets a session turn +# it on dynamically via the se:recordVideo capability. In the remaining case +# (legacy mode, recording off) video_ready.py's own handler would always +# answer "ready" anyway, so skipping it avoids binding the port for nothing - +# recorder.conf reads this to gate video-ready's autostart/autorestart. +# Set it directly to override either default, e.g. force it off under +# network_mode: host regardless of the two vars above. +if [ -z "${SE_VIDEO_READY_ENABLED}" ]; then + if [ "$(echo "${SE_RECORD_VIDEO:-true}" | tr '[:upper:]' '[:lower:]')" = "true" ] || + [ "$(echo "${SE_VIDEO_EVENT_DRIVEN:-false}" | tr '[:upper:]' '[:lower:]')" = "true" ]; then + export SE_VIDEO_READY_ENABLED=true + else + export SE_VIDEO_READY_ENABLED=false + fi +fi + supervisord --configuration /etc/supervisord.conf & SUPERVISOR_PID=$! diff --git a/Video/recorder.conf b/Video/recorder.conf index d60da93718..199d74d302 100755 --- a/Video/recorder.conf +++ b/Video/recorder.conf @@ -17,9 +17,9 @@ stdout_logfile_maxbytes=0 priority=0 command=python3 /opt/bin/video_ready.py killasgroup=true -autostart=true +autostart=%(ENV_SE_VIDEO_READY_ENABLED)s startsecs=0 -autorestart=true +autorestart=%(ENV_SE_VIDEO_READY_ENABLED)s stopsignal=TERM stopwaitsecs=5