diff --git a/ENV_VARIABLES.md b/ENV_VARIABLES.md index 0eef2eb2b..cbc9f3bee 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 5178e2e47..31af339c0 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 d60da9371..199d74d30 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