-
Notifications
You must be signed in to change notification settings - Fork 1
/
start.sh
executable file
·32 lines (27 loc) · 967 Bytes
/
start.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
#!/bin/bash
VARNISH_BACKEND_PORT=${VARNISH_BACKEND_PORT-80}
VARNISH_BACKEND_ELB=${VARNISH_BACKEND_ELB-example.com}
VARNISH_BACKEND_HOST=${VARNISH_BACKEND_HOST-example.com}
VARNISH_BACKEND_FORCE_SSL=${VARNISH_BACKEND_FORCE_SSL-false}
VARNISH_BACKEND_FORCE_SSL_HOST=${VARNISH_BACKEND_FORCE_SSL_HOST-example.com}
function replace_env() {
local file="${1?}"
shift
cp "${file}.in" "$file"
for name in "$@"; do
eval value=\$$name
sed -i "s|\${${name}}|${value}|g" "$file"
done
}
replace_env /etc/nginx/nginx.conf \
VARNISH_BACKEND_PORT \
VARNISH_BACKEND_ELB \
VARNISH_BACKEND_HOST \
VARNISH_BACKEND_FORCE_SSL \
VARNISH_BACKEND_FORCE_SSL_HOST
if [ -n "$DATADOG_API_KEY" ]; then
replace_env /etc/dd-agent/datadog.conf DATADOG_API_KEY DATADOG_TAGS
/etc/init.d/datadog-agent start
fi
/etc/init.d/nginx start
varnishd -F -f /etc/varnish/default.vcl -s malloc,100M -a 0.0.0.0:${VARNISH_PORT}