-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathentrypoint-tideways.sh
More file actions
executable file
·69 lines (52 loc) · 2.11 KB
/
Copy pathentrypoint-tideways.sh
File metadata and controls
executable file
·69 lines (52 loc) · 2.11 KB
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
#!/usr/bin/env sh
# if secret is set
if [ -f /run/secrets/tideways_api_key ]; then
TIDEWAYS_API_KEY=$(cat /run/secrets/tideways_api_key)
echo "Tideways secret found"
fi
# if secret(k8s) is set
if { [ -f /run/secrets/shared/tideways_api_key ] && [ ! -z "$APP_NAME" ];}; then
TIDEWAYS_API_KEY=$(cat /run/secrets/shared/tideways_api_key)
echo "Tideways secret found"
fi
# if env or secret is set
if [ ! -z "$TIDEWAYS_API_KEY" ]; then
TIDEWAYS_ENV="${TIDEWAYS_ENV:-${XEONYS_PLATFORM_ENV}}"
if [ "$TIDEWAYS_ENV" = "prod" ]; then
TIDEWAYS_ENV="production"
fi
echo "Tideways ENV $TIDEWAYS_ENV"
# try to get rancher container name
if [ "$K8S_CONTEXT" = "" ]; then
TIDEWAYS_HOST=${TIDEWAY_HOST:-$(curl -s rancher-metadata/latest/self/container/name)}
fi
if [ "$TIDEWAYS_HOST" = "" ]; then
TIDEWAYS_HOST=$(cat /etc/hostname)
fi
echo "Tideways HOST $TIDEWAYS_HOST"
TIDEWAYS_APP_NAME=${APP_NAME:-$(curl -s rancher-metadata/latest/self/stack/name)}
echo "Tideways APP_NAME $TIDEWAYS_APP_NAME"
TIDEWAYS_MONITOR_MODE=${TIDEWAYS_MONITOR_MODE:-BASIC}
echo "Tideways TIDEWAYS_MONITOR_MODE $TIDEWAYS_MONITOR_MODE"
TIDEWAYS_COLLECT_MODE=${TIDEWAYS_COLLECT_MODE:-TRACING}
echo "Tideways TIDEWAYS_COLLECT_MODE $TIDEWAYS_COLLECT_MODE"
# Configure tideway daemon with env vars
printf "\
TIDEWAYS_DAEMON_EXTRA=\"--hostname=${TIDEWAYS_HOST} --env=${TIDEWAYS_ENV} --server=${TIDEWAYS_PROXY} --insecure\" \n\
" | sudo tee /etc/default/tideways-daemon > /dev/null
# Configure tideway agent with env vars
printf "\
extension=tideways.so \n\
tideways.api_key=${TIDEWAYS_API_KEY} \n\
tideways.service=${TIDEWAYS_APP_NAME} \n\
tideways.framework=symfony2 \n\
tideways.sample_rate=25 \n\
tideways.monitor_cli=1 \n\
tideways.monitor=${TIDEWAYS_MONITOR_MODE} \n\
tideways.collect=${TIDEWAYS_COLLECT_MODE} \n\
" | sudo tee /usr/local/etc/php/conf.d/tideways.ini > /dev/null
# start daemon
sudo /etc/init.d/tideways-daemon start
fi
echo "continue to basic entrypoint with args $@"
exec /entrypoint.sh "$@"