Skip to content

Commit 6c0b2eb

Browse files
authored
Grabbing the display created by Xvfb and passing it to x11vnc (#779)
1 parent 96ffe69 commit 6c0b2eb

File tree

4 files changed

+29
-25
lines changed

4 files changed

+29
-25
lines changed

NodeBase/entry_point.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
5353
NODE_PID=$!
5454

5555
trap shutdown SIGTERM SIGINT
56-
wait $NODE_PID
56+
wait ${NODE_PID}

NodeDebug/entry_point.sh

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,33 +52,35 @@ fi
5252

5353
rm -f /tmp/.X*lock
5454

55-
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
55+
# Creating a file descriptor, where the DISPLAY will be saved ("6" was arbitrarily chosen)
56+
exec 6>/tmp/display.log
57+
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR -displayfd 6" \
5658
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
5759
-role node \
58-
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \
60+
-hub http://${HUB_PORT_4444_TCP_ADDR}:${HUB_PORT_4444_TCP_PORT}/grid/register \
5961
${REMOTE_HOST_PARAM} \
6062
-nodeConfig /opt/selenium/config.json \
6163
${SE_OPTS} &
6264
NODE_PID=$!
65+
exec 6>&-
6366

6467
trap shutdown SIGTERM SIGINT
6568
for i in $(seq 1 10)
6669
do
67-
DISPLAY=$(xvfb-run printenv DISPLAY)
68-
if [ -z "$DISPLAY" ]; then
69-
echo "\$DISPLAY env variable is empty"
70-
break
70+
sleep 1
71+
export DISPLAY=:$(cat /tmp/display.log)
72+
if [ "${DISPLAY}" != ":" ]; then
73+
echo "Display ${DISPLAY} allocated"
7174
fi
72-
xdpyinfo -display $DISPLAY >/dev/null 2>&1
75+
xdpyinfo -display ${DISPLAY} >/dev/null 2>&1
7376
if [ $? -eq 0 ]; then
7477
break
7578
fi
76-
echo Waiting xvfb...
77-
sleep 0.5
79+
echo "Waiting xvfb..."
7880
done
7981

80-
fluxbox -display $DISPLAY &
82+
fluxbox -display ${DISPLAY} &
8183

82-
x11vnc $X11VNC_OPTS -forever -shared -rfbport 5900 -display $DISPLAY &
84+
x11vnc ${X11VNC_OPTS} -forever -shared -rfbport 5900 -display ${DISPLAY} &
8385

84-
wait $NODE_PID
86+
wait ${NODE_PID}

Standalone/entry_point.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
2121
NODE_PID=$!
2222

2323
trap shutdown SIGTERM SIGINT
24-
wait $NODE_PID
24+
wait ${NODE_PID}

StandaloneDebug/entry_point.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,31 @@ fi
2222

2323
rm -f /tmp/.X*lock
2424

25-
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
25+
# Creating a file descriptor, where the DISPLAY will be saved ("6" was arbitrarily chosen)
26+
exec 6>/tmp/display.log
27+
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR -displayfd 6" \
2628
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
2729
${SE_OPTS} &
2830
NODE_PID=$!
31+
exec 6>&-
2932

3033
trap shutdown SIGTERM SIGINT
3134
for i in $(seq 1 10)
3235
do
33-
DISPLAY=$(xvfb-run printenv DISPLAY)
34-
if [ -z "$DISPLAY" ]; then
35-
echo "\$DISPLAY env variable is empty"
36-
break
36+
sleep 1
37+
export DISPLAY=:$(cat /tmp/display.log)
38+
if [ "${DISPLAY}" != ":" ]; then
39+
echo "Display ${DISPLAY} allocated"
3740
fi
38-
xdpyinfo -display $DISPLAY >/dev/null 2>&1
41+
xdpyinfo -display ${DISPLAY} >/dev/null 2>&1
3942
if [ $? -eq 0 ]; then
4043
break
4144
fi
42-
echo Waiting xvfb...
43-
sleep 0.5
45+
echo "Waiting xvfb..."
4446
done
4547

46-
fluxbox -display $DISPLAY &
48+
fluxbox -display ${DISPLAY} &
4749

48-
x11vnc $X11VNC_OPTS -forever -shared -rfbport 5900 -display $DISPLAY &
50+
x11vnc ${X11VNC_OPTS} -forever -shared -rfbport 5900 -display ${DISPLAY} &
4951

50-
wait $NODE_PID
52+
wait ${NODE_PID}

0 commit comments

Comments
 (0)