[e988c2]: / tests / support / trino / entrypoint.sh

Download this file

31 lines (25 with data), 981 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
set -euo pipefail
if [ "$1" = '/usr/lib/trino/bin/run-trino' ]; then
# If this is the container's first run, initialize the application
# database
if [ ! -f /tmp/app-initialized ]; then
# Initialize the application database asynchronously in a
# background process. This allows a) the trino process to be
# the main process in the container, which allows graceful
# shutdown and other goodies, and b) us to only start the trino
# process once, as opposed to starting, stopping, then
# starting it again.
function initialize_app_database() {
timeout=20
limit="$((SECONDS + timeout))"
# Note that the container has been initialized so future
# starts won't wipe changes to the data
touch /tmp/app-initialized
}
initialize_app_database &
fi
fi
# The Docker library we're using hides stdout from us if the container exits with an error, so send everything to
# stderr.
exec "$@" 1>&2