File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,8 @@ RUN apt-get update -y && \
9999 groupadd --gid ${USER_GID} ibgateway && \
100100 useradd -ms /bin/bash --uid ${USER_ID} --gid ${USER_GID} ibgateway && \
101101 echo "ibgateway ALL=(ALL) NOPASSWD:ALL" | tee -a /etc/sudoers && \
102- chmod a+x ${SCRIPT_PATH}/*.sh
102+ chmod a+x ${SCRIPT_PATH}/*.sh && \
103+ mkdir -p /tmp/.X11-unix && chmod 1777 /tmp/.X11-unix
103104
104105USER ${USER_ID}:${USER_GID}
105106WORKDIR ${HOME}
Original file line number Diff line number Diff line change @@ -263,3 +263,23 @@ start_socat() {
263263 fi
264264
265265}
266+
267+ wait_x_socket () {
268+ DISPLAY_NUM=${DISPLAY#: }
269+ # wait for X11 socket
270+ if [ -S " /tmp/.X11-unix/X${DISPLAY_NUM} " ]; then
271+ return 0
272+ fi
273+ echo " .> Waiting for Xvfb socket on $DISPLAY ..."
274+ timeout=50 # 50 * .2 = 10 seconds max wait
275+ elapsed=0
276+ while [ ! -S " /tmp/.X11-unix/X${DISPLAY_NUM} " ]; do
277+ sleep 0.2
278+ elapsed=$(( elapsed + 1 ))
279+ if [ $elapsed -ge $timeout ]; then
280+ echo " Error: Timed out waiting for Xvfb socket!"
281+ exit 1
282+ fi
283+ done
284+ echo " .> Xvfb socket ready!"
285+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ echo "*************************************************************************"
1111# shellcheck disable=SC1091
1212source " ${SCRIPT_PATH} /common.sh"
1313
14+ # shellcheck disable=SC2329
1415stop_ibc () {
1516 echo " .> 😘 Received SIGINT or SIGTERM. Shutting down IB Gateway."
1617
@@ -54,6 +55,8 @@ start_xvfb() {
5455}
5556
5657start_vnc () {
58+ # wait for X11 socket to be ready
59+ wait_x_socket
5760 # start VNC server
5861 file_env ' VNC_SERVER_PASSWORD'
5962 if [ -n " $VNC_SERVER_PASSWORD " ]; then
@@ -120,6 +123,7 @@ start_vnc
120123
121124# run scripts once X environment is up
122125if [ -n " $X_SCRIPTS " ]; then
126+ wait_x_socket
123127 run_scripts " $HOME /$X_SCRIPTS "
124128fi
125129
You can’t perform that action at this time.
0 commit comments