Skip to content

Commit

Permalink
Grabbing the display created by Xvfb and passing it to x11vnc (#779)
Browse files Browse the repository at this point in the history
  • Loading branch information
diemol committed Sep 2, 2018
1 parent 96ffe69 commit 6c0b2eb
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion NodeBase/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
NODE_PID=$!

trap shutdown SIGTERM SIGINT
wait $NODE_PID
wait ${NODE_PID}
26 changes: 14 additions & 12 deletions NodeDebug/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,33 +52,35 @@ fi

rm -f /tmp/.X*lock

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

trap shutdown SIGTERM SIGINT
for i in $(seq 1 10)
do
DISPLAY=$(xvfb-run printenv DISPLAY)
if [ -z "$DISPLAY" ]; then
echo "\$DISPLAY env variable is empty"
break
sleep 1
export DISPLAY=:$(cat /tmp/display.log)
if [ "${DISPLAY}" != ":" ]; then
echo "Display ${DISPLAY} allocated"
fi
xdpyinfo -display $DISPLAY >/dev/null 2>&1
xdpyinfo -display ${DISPLAY} >/dev/null 2>&1
if [ $? -eq 0 ]; then
break
fi
echo Waiting xvfb...
sleep 0.5
echo "Waiting xvfb..."
done

fluxbox -display $DISPLAY &
fluxbox -display ${DISPLAY} &

x11vnc $X11VNC_OPTS -forever -shared -rfbport 5900 -display $DISPLAY &
x11vnc ${X11VNC_OPTS} -forever -shared -rfbport 5900 -display ${DISPLAY} &

wait $NODE_PID
wait ${NODE_PID}
2 changes: 1 addition & 1 deletion Standalone/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
NODE_PID=$!

trap shutdown SIGTERM SIGINT
wait $NODE_PID
wait ${NODE_PID}
24 changes: 13 additions & 11 deletions StandaloneDebug/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,31 @@ fi

rm -f /tmp/.X*lock

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

trap shutdown SIGTERM SIGINT
for i in $(seq 1 10)
do
DISPLAY=$(xvfb-run printenv DISPLAY)
if [ -z "$DISPLAY" ]; then
echo "\$DISPLAY env variable is empty"
break
sleep 1
export DISPLAY=:$(cat /tmp/display.log)
if [ "${DISPLAY}" != ":" ]; then
echo "Display ${DISPLAY} allocated"
fi
xdpyinfo -display $DISPLAY >/dev/null 2>&1
xdpyinfo -display ${DISPLAY} >/dev/null 2>&1
if [ $? -eq 0 ]; then
break
fi
echo Waiting xvfb...
sleep 0.5
echo "Waiting xvfb..."
done

fluxbox -display $DISPLAY &
fluxbox -display ${DISPLAY} &

x11vnc $X11VNC_OPTS -forever -shared -rfbport 5900 -display $DISPLAY &
x11vnc ${X11VNC_OPTS} -forever -shared -rfbport 5900 -display ${DISPLAY} &

wait $NODE_PID
wait ${NODE_PID}

0 comments on commit 6c0b2eb

Please sign in to comment.