trap exit, inspired by docker selenium

This commit is contained in:
soulgalore 2016-12-12 16:15:30 +01:00 committed by Tobias Lidskog
parent a05d49a282
commit cc88f83a0b
1 changed files with 12 additions and 1 deletions

View File

@ -14,6 +14,17 @@ service dbus status > /dev/null
export $(dbus-launch)
export NSS_USE_SHARED_DB=ENABLED
# Inspired by docker-selenium way of shutting down
function shutdown {
kill -s SIGTERM $PID
wait $PID
}
MAX_OLD_SPACE_SIZE="${MAX_OLD_SPACE_SIZE:-2048}"
exec node --max-old-space-size=$MAX_OLD_SPACE_SIZE /usr/src/app/bin/sitespeed.js "$@"
exec node --max-old-space-size=$MAX_OLD_SPACE_SIZE /usr/src/app/bin/sitespeed.js "$@" &
PID=$!
trap shutdown SIGTERM SIGINT
wait $PID