forked from elgalu/docker-selenium
-
Notifications
You must be signed in to change notification settings - Fork 1
/
run-supervisord.sh
executable file
·79 lines (65 loc) · 1.91 KB
/
run-supervisord.sh
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
echoerr() { printf "%s\n" "$*" >&2; }
# print error and exit
die () {
echoerr "ERROR: $1"
# if $2 is defined AND NOT EMPTY, use $2; otherwise, set to "13"
errnum=${2-13}
exit $errnum
}
# Required params
[ -z "${TAIL_LOG_LINES}" ] && die "Required TAIL_LOG_LINES"
ga_track_shutdown () {
if [ "${SEND_ANONYMOUS_USAGE_INFO}" == "true" ]; then
DisplayDataProcessingAgreement
local args=(
--max-time 10
--data v=${GA_API_VERSION}
--data aip=1
--data t="screenview"
--data tid="${GA_TRACKING_ID}"
--data cid="${RANDOM_USER_GA_ID}"
--data an="dosel"
--data av="${DOSEL_VERSION}"
--data cd="shutdown"
--data sc="end"
--data ds="docker"
)
curl ${GA_ENDPOINT} "${args[@]}" \
--silent --output /dev/null >/dev/null 2>&1
fi
}
# Exit all child processes properly
shutdown () {
echo "Trapped SIGTERM/SIGINT/x so shutting down supervisord gracefully..."
ga_track_shutdown
stop
wait
# when DISABLE_ROLLBACK=true it will:
# - output logs
# - exec bash to permit troubleshooting
if [ "$(cat ${DOCKER_SELENIUM_STATUS})" = "failed" ]; then
tail --lines=${TAIL_LOG_LINES} /var/log/cont/*
echo "" && echo "" && echo "==> errors <=="
errors
if [ "${DISABLE_ROLLBACK}" = "true" ]; then
echo ""
echo "DEBUGGING: to find out what happened please analyze logs or run"
echo " errors"
echo ""
exec bash
else
exit 122
fi
else
exit 0
fi
}
# Run function shutdown() when this process receives a killing signal
trap shutdown SIGHUP SIGTERM SIGINT
echo -n "supervisord --version=" && supervisord --version
# supervisord -c /etc/supervisor/supervisord.conf --user ${USER} --nodaemon &
supervisord -c /etc/supervisor/supervisord.conf --nodaemon &
SUPERVISOR_PID=$!
# tells bash to wait until child processes have exited
wait "${SUPERVISOR_PID}"