Skip to content

Commit 73c67d6

Browse files
authored
Managing processes via Supervisor, this simplifies the configuration of (#793)
every process running in the containers, and allows to handle logging in a more simple way. Logging in node containers will be less noisy since only Selenium activity is logged to /std/out.
1 parent 1b75056 commit 73c67d6

31 files changed

+379
-284
lines changed

.gitignore

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ node_modules/
77
# Vim swap files.
88
*.swp
99

10-
# Ignoring the generated entry_point.sh files in different folders
11-
Node*Debug/entry_point.sh
12-
StandaloneC*/entry_point.sh
13-
StandaloneF*/entry_point.sh
10+
# Ignoring generated files during the build process
11+
Node*Debug/selenium-debug.conf
12+
Node*Debug/start-*.sh
13+
Standalone*/selenium.conf
14+
Standalone*/start-*.sh
1415

1516
# Created by https://www.gitignore.io/api/virtualenv
1617

Base/Dockerfile

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ RUN apt-get -qqy update \
2727
wget \
2828
jq \
2929
curl \
30+
supervisor \
3031
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
3132
&& sed -i 's/securerandom\.source=file:\/dev\/random/securerandom\.source=file:\/dev\/urandom/' ./usr/lib/jvm/java-8-openjdk-amd64/jre/lib/security/java.security
3233

@@ -55,12 +56,16 @@ ENV HOME=/home/seluser
5556
RUN mkdir -p /opt/bin
5657

5758
#======================================
58-
# Add intermediate service discovery
59+
# Add Grid check script
5960
#======================================
60-
COPY check-grid.sh \
61-
/opt/bin/
61+
COPY check-grid.sh /opt/bin/
6262
RUN chmod +x /opt/bin/check-grid.sh
6363

64+
#======================================
65+
# Add Supervisor configuration file
66+
#======================================
67+
COPY supervisord.conf /etc
68+
6469
#===================================================
6570
# Run the following commands as non-privileged user
6671
#===================================================
@@ -74,4 +79,11 @@ RUN sudo mkdir -p /opt/selenium \
7479
&& wget --no-verbose https://selenium-release.storage.googleapis.com/3.14/selenium-server-standalone-3.14.0.jar \
7580
-O /opt/selenium/selenium-server-standalone.jar \
7681
&& sudo chgrp -R 0 /opt/selenium $HOME \
77-
&& sudo chmod -R g=u /opt/selenium $HOME
82+
&& sudo chmod -R g=u /opt/selenium $HOME \
83+
&& sudo mkdir -p /var/run/supervisor/ \
84+
&& sudo mkdir -p /var/log/supervisor/ \
85+
&& sudo chown -R seluser:seluser /var/run/supervisor \
86+
&& sudo chown -R seluser:seluser /var/log/supervisor
87+
88+
89+
CMD ["/usr/bin/supervisord", "--configuration", "/etc/supervisord.conf"]

Base/supervisord.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
; Documentation of this file format -> http://supervisord.org/configuration.html
2+
3+
[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)
6+
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
7+
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
8+
loglevel=info ; (log level;default info; others: debug,warn,trace)
9+
pidfile=/var/run/supervisor/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
10+
nodaemon=true ; (start in foreground if true;default false)
11+
minfds=1024 ; (min. avail startup file descriptors;default 1024)
12+
minprocs=200 ; (min. avail process descriptors;default 200)
13+
14+
[include]
15+
files = /etc/supervisor/conf.d/*.conf

Hub/Dockerfile.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ ENV GRID_HUB_PORT 4444
2828
ENV GRID_HUB_HOST "0.0.0.0"
2929

3030
COPY generate_config \
31-
entry_point.sh \
31+
start-selenium-hub.sh \
3232
/opt/bin/
3333

34-
RUN /opt/bin/generate_config > /opt/selenium/config.json
34+
COPY selenium-hub.conf /etc/supervisor/conf.d/
3535

36-
CMD ["/opt/bin/entry_point.sh"]
36+
RUN /opt/bin/generate_config > /opt/selenium/config.json

Hub/entry_point.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

Hub/generate.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
23
VERSION=$1
34
NAMESPACE=$2
45
AUTHORS=$3
@@ -7,7 +8,7 @@ echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > ./Dockerfile
78
echo "# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED." >> ./Dockerfile
89
echo "# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE" >> ./Dockerfile
910
echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ./Dockerfile
10-
echo FROM $NAMESPACE/base:$VERSION >> ./Dockerfile
11+
echo FROM ${NAMESPACE}/base:${VERSION} >> ./Dockerfile
1112
echo LABEL authors="$AUTHORS" >> ./Dockerfile
1213
echo "" >> ./Dockerfile
13-
cat ./Dockerfile.txt >> ./Dockerfile
14+
cat ./Dockerfile.txt >> ./Dockerfile

Hub/generate_config

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

33
cat <<_EOF
44
{
5-
"host": "$GRID_HUB_HOST",
6-
"port": $GRID_HUB_PORT,
5+
"host": "${GRID_HUB_HOST}",
6+
"port": ${GRID_HUB_PORT},
77
"role": "hub",
8-
"maxSession": $GRID_MAX_SESSION,
9-
"newSessionWaitTimeout": $GRID_NEW_SESSION_WAIT_TIMEOUT,
8+
"maxSession": ${GRID_MAX_SESSION},
9+
"newSessionWaitTimeout": ${GRID_NEW_SESSION_WAIT_TIMEOUT},
1010
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
11-
"throwOnCapabilityNotPresent": $GRID_THROW_ON_CAPABILITY_NOT_PRESENT,
12-
"jettyMaxThreads": $GRID_JETTY_MAX_THREADS,
13-
"cleanUpCycle": $GRID_CLEAN_UP_CYCLE,
14-
"browserTimeout": $GRID_BROWSER_TIMEOUT,
15-
"timeout": $GRID_TIMEOUT,
16-
"debug": $GRID_DEBUG
11+
"throwOnCapabilityNotPresent": ${GRID_THROW_ON_CAPABILITY_NOT_PRESENT},
12+
"jettyMaxThreads": ${GRID_JETTY_MAX_THREADS},
13+
"cleanUpCycle": ${GRID_CLEAN_UP_CYCLE},
14+
"browserTimeout": ${GRID_BROWSER_TIMEOUT},
15+
"timeout": ${GRID_TIMEOUT},
16+
"debug": ${GRID_DEBUG}
1717
}
1818
_EOF

Hub/selenium-hub.conf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
; Documentation of this file format -> http://supervisord.org/configuration.html
2+
3+
[program:selenium-hub]
4+
5+
priority=0
6+
user=seluser
7+
command=/opt/bin/start-selenium-hub.sh
8+
autostart=true
9+
autorestart=false
10+
startsecs=0
11+
startretries=0
12+
13+
;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs"
14+
redirect_stderr=true
15+
stdout_logfile=/dev/stdout
16+
stdout_logfile_maxbytes=0

Hub/start-selenium-hub.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
# set -e: exit asap if a command exits with a non-zero status
4+
set -e
5+
6+
ROOT=/opt/selenium
7+
CONF=${ROOT}/config.json
8+
9+
/opt/bin/generate_config >${CONF}
10+
11+
echo "Starting Selenium Hub with configuration:"
12+
cat ${CONF}
13+
14+
if [ ! -z "$SE_OPTS" ]; then
15+
echo "Appending Selenium options: ${SE_OPTS}"
16+
fi
17+
18+
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
19+
-role hub \
20+
-hubConfig ${CONF} \
21+
${SE_OPTS}

NodeBase/Dockerfile.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,25 @@ RUN apt-get -qqy update \
7070
USER seluser
7171

7272
#==============================
73-
# Scripts to run Selenium Node
73+
# Scripts to run Selenium Node and XVFB
7474
#==============================
75-
COPY entry_point.sh /opt/bin/
75+
COPY start-selenium-node.sh \
76+
start-xvfb.sh \
77+
/opt/bin/
78+
79+
#==============================
80+
# Supervisor configuration file
81+
#==============================
82+
COPY selenium.conf /etc/supervisor/conf.d/
83+
7684

7785
#============================
7886
# Some configuration options
7987
#============================
8088
ENV SCREEN_WIDTH 1360
8189
ENV SCREEN_HEIGHT 1020
8290
ENV SCREEN_DEPTH 24
91+
ENV DISPLAY :99.0
8392

8493
#========================
8594
# Selenium Configuration
@@ -106,4 +115,5 @@ ENV NODE_APPLICATION_NAME ""
106115
# Following line fixes https://github.com/SeleniumHQ/docker-selenium/issues/87
107116
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null
108117

109-
CMD ["/opt/bin/entry_point.sh"]
118+
# Creating base directory for Xvfb
119+
RUN sudo mkdir -p /tmp/.X11-unix && sudo chmod 1777 /tmp/.X11-unix

0 commit comments

Comments
 (0)