Skip to content

Commit

Permalink
update: config supervisord via ENV variables
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Nguyen Duc <[email protected]>
  • Loading branch information
VietND96 committed Sep 7, 2024
1 parent 44d8bb5 commit b53dc3f
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 12 deletions.
3 changes: 3 additions & 0 deletions Base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ ENV SE_BIND_HOST=false \
SE_OTEL_JAVA_GLOBAL_AUTOCONFIGURE_ENABLED=true \
SE_OTEL_TRACES_EXPORTER="otlp" \
SE_SUPERVISORD_LOG_LEVEL="info" \
SE_SUPERVISORD_CHILD_LOG_DIR="/tmp" \
SE_SUPERVISORD_LOG_FILE="/tmp/supervisord.log" \
SE_SUPERVISORD_PID_FILE="/tmp/supervisord.pid" \
SE_LOG_LEVEL="INFO" \
SE_HTTP_LOGS=false \
SE_STRUCTURED_LOGS=false \
Expand Down
6 changes: 3 additions & 3 deletions Base/supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
; Documentation of this file format -> http://supervisord.org/configuration.html

[supervisord]
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
childlogdir=%(ENV_SE_SUPERVISORD_CHILD_LOG_DIR)s ; ('AUTO' child log dir, default $TEMP)
logfile=%(ENV_SE_SUPERVISORD_LOG_FILE)s ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=%(ENV_SE_SUPERVISORD_LOG_LEVEL)s ; (log level;default info; others: debug,warn,trace) http://supervisord.org/logging.html
pidfile=/var/run/supervisor/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
pidfile=%(ENV_SE_SUPERVISORD_PID_FILE)s ; (supervisord pidfile;default supervisord.pid)
nodaemon=true ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
Expand Down
2 changes: 1 addition & 1 deletion NodeBase/selenium.conf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ stderr_capture_maxbytes=50MB

[program:selenium-node]
priority=15
command=bash -c "/opt/bin/start-selenium-node.sh; EXIT_CODE=$?; kill -s SIGINT `cat /var/run/supervisor/supervisord.pid`; exit $EXIT_CODE"
command=bash -c "/opt/bin/start-selenium-node.sh; EXIT_CODE=$?; kill -s SIGINT `cat ${SE_SUPERVISORD_PID_FILE}`; exit $EXIT_CODE"
stopasgroup = true
killasgroup=true
autostart=true
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Talk to us at https://www.selenium.dev/support/
* [Mask sensitive information in console logs](#mask-sensitive-information-in-console-logs)
* [Secure Connection](#secure-connection)
* [Browser language and locale](#browser-language-and-locale)
* [Managing processes in container](#managing-processes-in-container)
* [Building the images](#building-the-images)
* [Build the images with specific versions](#build-the-images-with-specific-versions)
* [Upgrade browser version in the images](#upgrade-browser-version-in-the-images)
Expand Down Expand Up @@ -785,7 +786,7 @@ host-config-keys = ["Binds"]

Volumes config in docker compose file

```dockerfile
```yaml
services:
node-docker:
image: selenium/node-docker:latest
Expand Down Expand Up @@ -1309,6 +1310,17 @@ FIREFOX_VERSION=$(docker run --rm --entrypoint="" selenium/node-firefox:latest f

Or, you can mount the container directory `/home/seluser/firefox/distribution/extensions` to host directory to access packs were pre-built in the container for using in your test script.

## Managing processes in container

[Supervisor](http://supervisord.org/configuration.html) is used to manage processes and logs in the container. Few configuration for `supervisord` can be set via environment variables as below:

| Environment variables | Default | `supervisord` config |
|------------------------------|------------------------|-------------------------|
| SE_SUPERVISORD_LOG_LEVEL | `info` | supervisord.loglevel |
| SE_SUPERVISORD_CHILD_LOG_DIR | `/tmp` | supervisord.childlogdir |
| SE_SUPERVISORD_LOG_FILE | `/tmp/supervisord.log` | supervisord.logfile |
| SE_SUPERVISORD_PID_FILE | `/tmp/supervisord.pid` | supervisord.pidfile |

___

## Building the images
Expand Down
2 changes: 1 addition & 1 deletion Standalone/selenium.conf
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ stderr_capture_maxbytes=50MB

[program:selenium-standalone]
priority=15
command=bash -c "/opt/bin/start-selenium-standalone.sh; EXIT_CODE=$?; kill -s SIGINT `cat /var/run/supervisor/supervisord.pid`; exit $EXIT_CODE"
command=bash -c "/opt/bin/start-selenium-standalone.sh; EXIT_CODE=$?; kill -s SIGINT `cat ${SE_SUPERVISORD_PID_FILE}`; exit $EXIT_CODE"
stopasgroup = true
autostart=true
autorestart=false
Expand Down
5 changes: 4 additions & 1 deletion Video/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ ENV DISPLAY_NUM=99 \
VIDEO_FOLDER=${VIDEO_FOLDER} \
SE_VIDEO_FILE_NAME=video.mp4 \
SE_VIDEO_FILE_NAME_TRIM_REGEX="[:alnum:]-_" \
SE_SUPERVISORD_LOG_LEVEL="info"
SE_SUPERVISORD_LOG_LEVEL="info" \
SE_SUPERVISORD_CHILD_LOG_DIR="/tmp" \
SE_SUPERVISORD_LOG_FILE="/tmp/supervisord.log" \
SE_SUPERVISORD_PID_FILE="/tmp/supervisord.pid"

EXPOSE 9000
6 changes: 3 additions & 3 deletions Video/supervisord.conf
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
; Documentation of this file format -> http://supervisord.org/configuration.html

[supervisord]
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
childlogdir=%(ENV_SE_SUPERVISORD_CHILD_LOG_DIR)s ; ('AUTO' child log dir, default $TEMP)
logfile=%(ENV_SE_SUPERVISORD_LOG_FILE)s ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=%(ENV_SE_SUPERVISORD_LOG_LEVEL)s ; (log level;default info; others: debug,warn,trace) http://supervisord.org/logging.html
pidfile=/var/run/supervisor/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
pidfile=%(ENV_SE_SUPERVISORD_PID_FILE)s ; (supervisord pidfile;default supervisord.pid)
nodaemon=true ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
Expand Down
2 changes: 1 addition & 1 deletion Video/video.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function graceful_exit() {
stop_if_recording_inprogress
send_exit_signal_to_uploader
wait_util_uploader_shutdown
kill -SIGTERM "$(cat /var/run/supervisor/supervisord.pid)" 2>/dev/null
kill -SIGTERM "$(cat ${SE_SUPERVISORD_PID_FILE})" 2>/dev/null
echo "$(date +%FT%T%Z) [${process_name}] - Ready to shutdown the recorder"
exit 0
}
Expand Down
2 changes: 1 addition & 1 deletion charts/selenium-grid/CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
| https://jaegertracing.github.io/helm-charts | jaeger | 3.2.0 |
| https://kedacore.github.io/charts | keda | 2.15.1 |
| https://kubernetes.github.io/ingress-nginx | ingress-nginx | 4.11.2 |
| https://prometheus-community.github.io/helm-charts | kube-prometheus-stack | 62.3.1 |
| https://prometheus-community.github.io/helm-charts | kube-prometheus-stack | 62.5.0 |

## Values

Expand Down
3 changes: 3 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def signal_handler(signum, frame):
no_proxy = os.environ.get('no_proxy', '')
SKIP_BUILD = os.environ.get('SKIP_BUILD', False)
PLATFORMS = os.environ.get('PLATFORMS', 'linux/amd64')
FILESYSTEM_READ_ONLY = os.environ.get('FILESYSTEM_READ_ONLY', 'false').lower() == 'true'
BASE_VERSION = os.environ.get('BASE_VERSION')
BASE_RELEASE = os.environ.get('BASE_RELEASE')

Expand Down Expand Up @@ -200,6 +201,8 @@ def launch_container(container, **kwargs):
detach=True,
environment=environment,
shm_size="2G",
read_only=FILESYSTEM_READ_ONLY,
tmpfs={'/tmp': 'rw'},
**kwargs).short_id
logger.info("%s up and running" % container)
return container_id
Expand Down

0 comments on commit b53dc3f

Please sign in to comment.