Trying to modify run.sh so it waits for the Xvfb server to start accepting connections.
This commit is contained in:
parent
fac50c9bc6
commit
6f54d9228a
1 changed files with 13 additions and 8 deletions
21
run.sh
21
run.sh
|
@ -1,7 +1,7 @@
|
||||||
#!/bin/bash
|
#!/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
|
|
||||||
|
|
||||||
let p=80
|
# Find an open port
|
||||||
|
let p=99
|
||||||
while [ ${p} -lt 3000 ]
|
while [ ${p} -lt 3000 ]
|
||||||
do
|
do
|
||||||
if nc -z localhost ${p}; then
|
if nc -z localhost ${p}; then
|
||||||
|
@ -11,15 +11,20 @@ while [ ${p} -lt 3000 ]
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo The port is ${port}
|
|
||||||
|
|
||||||
if ${port}; then
|
if ${port}; then
|
||||||
|
echo The display port will be ${port}
|
||||||
|
start-stop-daemon --start --pidfile ~/xvfb.pid --make-pidfile --background \
|
||||||
|
--exec /usr/bin/Xvfb -- :${port} -screen 0 1024x768x24 \
|
||||||
|
-ac +extension GLX +render -noreset
|
||||||
|
|
||||||
|
# Wait to be able to connect to the port. This will exit if it cannot in 15 minutes.
|
||||||
timeout 15 bash -c "until echo > /dev/tcp/localhost/${port}; do sleep 0.5; done"
|
timeout 15 bash -c "until echo > /dev/tcp/localhost/${port}; do sleep 0.5; done"
|
||||||
|
export DISPLAY=:${port}.0
|
||||||
|
|
||||||
|
cd /data
|
||||||
|
node /usr/src/app/ -p 80 "$@"
|
||||||
else
|
else
|
||||||
|
echo "Could get a display port ${port}."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export DISPLAY=:${port}.0
|
|
||||||
|
|
||||||
cd /data
|
|
||||||
node /usr/src/app/ -p 80 "$@"
|
|
||||||
|
|
Loading…
Reference in a new issue