Trying to modify run.sh so it waits for the Xvfb server to start accepting connections.

This commit is contained in:
polar 2017-09-20 09:41:47 -04:00
parent 41046c2837
commit 15dc14f5b6
2 changed files with 19 additions and 2 deletions

View file

@ -15,6 +15,7 @@ RUN apt-get -qq update \
libprotobuf-dev \
libxxf86vm-dev \
xvfb \
netcat \
&& echo "deb https://deb.nodesource.com/node_6.x stretch main" >> /etc/apt/sources.list.d/nodejs.list \
&& echo "deb-src https://deb.nodesource.com/node_6.x stretch main" >> /etc/apt/sources.list.d/nodejs.list \
&& apt-get -qq update \

20
run.sh
View file

@ -1,9 +1,25 @@
#!/bin/bash
start-stop-daemon --start --pidfile ~/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
timeout 15 bash -c 'until echo > /dev/tcp/localhost/99; do sleep 0.5; done'
let p=80
while [ ${p} -lt 3000 ]
do
if nc -z localhost ${p}; then
let p+=1
else
let port=p
break
fi
done
echo The port is ${port}
export DISPLAY=:99.0
if ${port}; then
timeout 15 bash -c "until echo > /dev/tcp/localhost/${port}; do sleep 0.5; done"
else
exit 1
fi
export DISPLAY=:${port}.0
cd /data
node /usr/src/app/ -p 80 "$@"