Merge pull request #313 from guenhter/ensure-xvfb-started
Wait for Xvfb to startup
This commit is contained in:
commit
0631a76a51
2 changed files with 20 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
||||||
FROM node:6-stretch
|
FROM node:6.15.1-stretch
|
||||||
MAINTAINER Petr Sloup <petr.sloup@klokantech.com>
|
MAINTAINER Petr Sloup <petr.sloup@klokantech.com>
|
||||||
|
|
||||||
ENV NODE_ENV="production"
|
ENV NODE_ENV="production"
|
||||||
|
@ -21,6 +21,7 @@ RUN apt-get -qq update \
|
||||||
libprotobuf-dev \
|
libprotobuf-dev \
|
||||||
libxxf86vm-dev \
|
libxxf86vm-dev \
|
||||||
xvfb \
|
xvfb \
|
||||||
|
x11-utils \
|
||||||
&& apt-get clean
|
&& apt-get clean
|
||||||
|
|
||||||
RUN mkdir -p /usr/src/app
|
RUN mkdir -p /usr/src/app
|
||||||
|
|
24
run.sh
24
run.sh
|
@ -5,17 +5,29 @@ _term() {
|
||||||
kill -TERM "$child" 2>/dev/null
|
kill -TERM "$child" 2>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
trap _term TERM
|
trap _term SIGTERM
|
||||||
|
trap _term SIGINT
|
||||||
|
|
||||||
|
xvfbMaxStartWaitTime=5
|
||||||
|
displayNumber=99
|
||||||
|
screenNumber=0
|
||||||
|
|
||||||
# Delete files if they were not cleaned by last run
|
# Delete files if they were not cleaned by last run
|
||||||
rm -rf /tmp/.X11-unix /tmp/.X99-lock
|
rm -rf /tmp/.X11-unix /tmp/.X${displayNumber}-lock ~/xvfb.pid
|
||||||
|
|
||||||
start-stop-daemon --start --pidfile ~/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
|
echo "Starting Xvfb on display ${displayNumber}"
|
||||||
echo "Waiting 3 seconds for xvfb to start..."
|
start-stop-daemon --start --pidfile ~/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :${displayNumber} -screen ${screenNumber} 1024x768x24 -ac +extension GLX +render -noreset
|
||||||
sleep 3
|
|
||||||
|
|
||||||
export DISPLAY=:99.0
|
# Wait to be able to connect to the port. This will exit if it cannot in 15 minutes.
|
||||||
|
timeout ${xvfbMaxStartWaitTime} bash -c "while ! xdpyinfo -display :${displayNumber} >/dev/null; do sleep 0.5; done"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "Could not connect to display ${displayNumber} in ${xvfbMaxStartWaitTime} seconds time."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
export DISPLAY=:${displayNumber}.${screenNumber}
|
||||||
|
|
||||||
|
echo
|
||||||
cd /data
|
cd /data
|
||||||
node /usr/src/app/ -p 80 "$@" &
|
node /usr/src/app/ -p 80 "$@" &
|
||||||
child=$!
|
child=$!
|
||||||
|
|
Loading…
Reference in a new issue