
Node can't be PID 1, else it can't be term'ed and xvfb won't stop nicely. So, according to https://docs.docker.com/engine/reference/builder/#entrypoint, we need to make sure it's not the bare entrypoint. Also we need to be sure that run.sh passes the signal through to node, see https://unix.stackexchange.com/questions/146756/forward-sigterm-to-child-in-bash
23 lines
508 B
Bash
Executable file
23 lines
508 B
Bash
Executable file
#!/bin/bash
|
|
|
|
_term() {
|
|
echo "Caught signal, stopping gracefully"
|
|
kill -TERM "$child" 2>/dev/null
|
|
}
|
|
|
|
trap _term TERM
|
|
|
|
|
|
start-stop-daemon --start --pidfile ~/xvfb.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -screen 0 1024x768x24 -ac +extension GLX +render -noreset
|
|
echo "Waiting 3 seconds for xvfb to start..."
|
|
sleep 3
|
|
|
|
export DISPLAY=:99.0
|
|
|
|
cd /data
|
|
node /usr/src/app/ -p 80 "$@" &
|
|
child=$!
|
|
wait "$child"
|
|
|
|
start-stop-daemon --stop --pidfile ~/xvfb.pid # stop xvfb when exiting
|
|
rm ~/xvfb.pid
|