Trying to modify run.sh so it waits for the Xvfb server to start accepting connections.
This commit is contained in:
parent
d17a6cc23b
commit
6488d7d3ad
1 changed files with 17 additions and 26 deletions
43
run.sh
43
run.sh
|
@ -1,36 +1,27 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Find an open port
|
function LOG {
|
||||||
let p=99
|
echo $(date -R): $0: $*
|
||||||
while [ ${p} -lt 3000 ]
|
}
|
||||||
do
|
|
||||||
if nc -z localhost ${p}; then
|
|
||||||
let p+=1
|
|
||||||
else
|
|
||||||
let port=p
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
let timeout=20
|
displayNumber=1
|
||||||
|
screenNumber=0
|
||||||
|
export DISPLAY=:${displayNumber}.${screenNumber}
|
||||||
|
|
||||||
if [ "${port}" != "" ]; then
|
LOG "Starting Xvfb on ${DISPLAY}"
|
||||||
echo "The display port will be ${port}."
|
|
||||||
start-stop-daemon --start --pidfile ~/xvfb.pid --make-pidfile --background \
|
start-stop-daemon --start --pidfile ~/xvfb.pid --make-pidfile --background \
|
||||||
--exec /usr/bin/Xvfb -- :${port} -screen 0 1024x768x24 \
|
--exec /usr/bin/Xvfb -- :${displayNumber} -screen ${screenNumber} 1024x768x24 \
|
||||||
-ac +extension GLX +render -noreset
|
-ac +extension GLX +render -noreset
|
||||||
|
|
||||||
# Wait to be able to connect to the port. This will exit if it cannot in 15 minutes.
|
LOG "Waiting for display at ${DISPLAY}."
|
||||||
timeout ${timeout} bash -c "while ! nc -z localhost ${port}; do sleep 0.5; done"
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
export DISPLAY=:${port}.0
|
|
||||||
|
|
||||||
cd /data
|
# Wait to be able to connect to the port. This will exit if it cannot in 15 minutes.
|
||||||
node /usr/src/app/ -p 80 "$@"
|
timeout ${timeout} bash -c "while ! xdpyinfo >/dev/null 2>&1; do sleep 0.5; done"
|
||||||
else
|
if [ $? -eq 0 ]; then
|
||||||
echo "Could not connect to display port ${port} in ${timeout} seconds time."
|
LOG "Display ${DISPLAY} is up."
|
||||||
fi
|
LOG "Starting tileserver"
|
||||||
|
cd /data
|
||||||
|
node /usr/src/app/ -p 80 "$@"
|
||||||
else
|
else
|
||||||
echo "Could not get a display port."
|
LOG "Could not connect to display port ${DSIPLAY} in ${timeout} seconds time."
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue