Skip to content

Commit b53dc3f

Browse files
committed
update: config supervisord via ENV variables
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent 44d8bb5 commit b53dc3f

File tree

10 files changed

+33
-12
lines changed

10 files changed

+33
-12
lines changed

Base/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ ENV SE_BIND_HOST=false \
159159
SE_OTEL_JAVA_GLOBAL_AUTOCONFIGURE_ENABLED=true \
160160
SE_OTEL_TRACES_EXPORTER="otlp" \
161161
SE_SUPERVISORD_LOG_LEVEL="info" \
162+
SE_SUPERVISORD_CHILD_LOG_DIR="/tmp" \
163+
SE_SUPERVISORD_LOG_FILE="/tmp/supervisord.log" \
164+
SE_SUPERVISORD_PID_FILE="/tmp/supervisord.pid" \
162165
SE_LOG_LEVEL="INFO" \
163166
SE_HTTP_LOGS=false \
164167
SE_STRUCTURED_LOGS=false \

Base/supervisord.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
; Documentation of this file format -> http://supervisord.org/configuration.html
22

33
[supervisord]
4-
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
5-
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
4+
childlogdir=%(ENV_SE_SUPERVISORD_CHILD_LOG_DIR)s ; ('AUTO' child log dir, default $TEMP)
5+
logfile=%(ENV_SE_SUPERVISORD_LOG_FILE)s ; (main log file;default $CWD/supervisord.log)
66
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
77
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
88
loglevel=%(ENV_SE_SUPERVISORD_LOG_LEVEL)s ; (log level;default info; others: debug,warn,trace) http://supervisord.org/logging.html
9-
pidfile=/var/run/supervisor/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
9+
pidfile=%(ENV_SE_SUPERVISORD_PID_FILE)s ; (supervisord pidfile;default supervisord.pid)
1010
nodaemon=true ; (start in foreground if true;default false)
1111
minfds=1024 ; (min. avail startup file descriptors;default 1024)
1212
minprocs=200 ; (min. avail process descriptors;default 200)

NodeBase/selenium.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ stderr_capture_maxbytes=50MB
5858

5959
[program:selenium-node]
6060
priority=15
61-
command=bash -c "/opt/bin/start-selenium-node.sh; EXIT_CODE=$?; kill -s SIGINT `cat /var/run/supervisor/supervisord.pid`; exit $EXIT_CODE"
61+
command=bash -c "/opt/bin/start-selenium-node.sh; EXIT_CODE=$?; kill -s SIGINT `cat ${SE_SUPERVISORD_PID_FILE}`; exit $EXIT_CODE"
6262
stopasgroup = true
6363
killasgroup=true
6464
autostart=true

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Talk to us at https://www.selenium.dev/support/
6868
* [Mask sensitive information in console logs](#mask-sensitive-information-in-console-logs)
6969
* [Secure Connection](#secure-connection)
7070
* [Browser language and locale](#browser-language-and-locale)
71+
* [Managing processes in container](#managing-processes-in-container)
7172
* [Building the images](#building-the-images)
7273
* [Build the images with specific versions](#build-the-images-with-specific-versions)
7374
* [Upgrade browser version in the images](#upgrade-browser-version-in-the-images)
@@ -785,7 +786,7 @@ host-config-keys = ["Binds"]
785786

786787
Volumes config in docker compose file
787788

788-
```dockerfile
789+
```yaml
789790
services:
790791
node-docker:
791792
image: selenium/node-docker:latest
@@ -1309,6 +1310,17 @@ FIREFOX_VERSION=$(docker run --rm --entrypoint="" selenium/node-firefox:latest f
13091310

13101311
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.
13111312

1313+
## Managing processes in container
1314+
1315+
[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:
1316+
1317+
| Environment variables | Default | `supervisord` config |
1318+
|------------------------------|------------------------|-------------------------|
1319+
| SE_SUPERVISORD_LOG_LEVEL | `info` | supervisord.loglevel |
1320+
| SE_SUPERVISORD_CHILD_LOG_DIR | `/tmp` | supervisord.childlogdir |
1321+
| SE_SUPERVISORD_LOG_FILE | `/tmp/supervisord.log` | supervisord.logfile |
1322+
| SE_SUPERVISORD_PID_FILE | `/tmp/supervisord.pid` | supervisord.pidfile |
1323+
13121324
___
13131325

13141326
## Building the images

Standalone/selenium.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ stderr_capture_maxbytes=50MB
6161

6262
[program:selenium-standalone]
6363
priority=15
64-
command=bash -c "/opt/bin/start-selenium-standalone.sh; EXIT_CODE=$?; kill -s SIGINT `cat /var/run/supervisor/supervisord.pid`; exit $EXIT_CODE"
64+
command=bash -c "/opt/bin/start-selenium-standalone.sh; EXIT_CODE=$?; kill -s SIGINT `cat ${SE_SUPERVISORD_PID_FILE}`; exit $EXIT_CODE"
6565
stopasgroup = true
6666
autostart=true
6767
autorestart=false

Video/Dockerfile

+4-1
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ ENV DISPLAY_NUM=99 \
110110
VIDEO_FOLDER=${VIDEO_FOLDER} \
111111
SE_VIDEO_FILE_NAME=video.mp4 \
112112
SE_VIDEO_FILE_NAME_TRIM_REGEX="[:alnum:]-_" \
113-
SE_SUPERVISORD_LOG_LEVEL="info"
113+
SE_SUPERVISORD_LOG_LEVEL="info" \
114+
SE_SUPERVISORD_CHILD_LOG_DIR="/tmp" \
115+
SE_SUPERVISORD_LOG_FILE="/tmp/supervisord.log" \
116+
SE_SUPERVISORD_PID_FILE="/tmp/supervisord.pid"
114117

115118
EXPOSE 9000

Video/supervisord.conf

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
; Documentation of this file format -> http://supervisord.org/configuration.html
22

33
[supervisord]
4-
childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP)
5-
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
4+
childlogdir=%(ENV_SE_SUPERVISORD_CHILD_LOG_DIR)s ; ('AUTO' child log dir, default $TEMP)
5+
logfile=%(ENV_SE_SUPERVISORD_LOG_FILE)s ; (main log file;default $CWD/supervisord.log)
66
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
77
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
88
loglevel=%(ENV_SE_SUPERVISORD_LOG_LEVEL)s ; (log level;default info; others: debug,warn,trace) http://supervisord.org/logging.html
9-
pidfile=/var/run/supervisor/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
9+
pidfile=%(ENV_SE_SUPERVISORD_PID_FILE)s ; (supervisord pidfile;default supervisord.pid)
1010
nodaemon=true ; (start in foreground if true;default false)
1111
minfds=1024 ; (min. avail startup file descriptors;default 1024)
1212
minprocs=200 ; (min. avail process descriptors;default 200)

Video/video.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ function graceful_exit() {
172172
stop_if_recording_inprogress
173173
send_exit_signal_to_uploader
174174
wait_util_uploader_shutdown
175-
kill -SIGTERM "$(cat /var/run/supervisor/supervisord.pid)" 2>/dev/null
175+
kill -SIGTERM "$(cat ${SE_SUPERVISORD_PID_FILE})" 2>/dev/null
176176
echo "$(date +%FT%T%Z) [${process_name}] - Ready to shutdown the recorder"
177177
exit 0
178178
}

charts/selenium-grid/CONFIGURATION.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A Helm chart for creating a Selenium Grid Server in Kubernetes
2121
| https://jaegertracing.github.io/helm-charts | jaeger | 3.2.0 |
2222
| https://kedacore.github.io/charts | keda | 2.15.1 |
2323
| https://kubernetes.github.io/ingress-nginx | ingress-nginx | 4.11.2 |
24-
| https://prometheus-community.github.io/helm-charts | kube-prometheus-stack | 62.3.1 |
24+
| https://prometheus-community.github.io/helm-charts | kube-prometheus-stack | 62.5.0 |
2525

2626
## Values
2727

tests/test.py

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def signal_handler(signum, frame):
4646
no_proxy = os.environ.get('no_proxy', '')
4747
SKIP_BUILD = os.environ.get('SKIP_BUILD', False)
4848
PLATFORMS = os.environ.get('PLATFORMS', 'linux/amd64')
49+
FILESYSTEM_READ_ONLY = os.environ.get('FILESYSTEM_READ_ONLY', 'false').lower() == 'true'
4950
BASE_VERSION = os.environ.get('BASE_VERSION')
5051
BASE_RELEASE = os.environ.get('BASE_RELEASE')
5152

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

0 commit comments

Comments
 (0)