-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfd-watch
32 lines (23 loc) · 888 Bytes
/
confd-watch
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
# Fail hard and fast
set -eo pipefail
export ETCD_PORT=${ETCD_PORT:-4001}
export HOST_IP=${HOST_IP:-172.17.42.1}
export ETCD=$HOST_IP:4001
export confdKey=${confdKey:-"/service"}
echo "[confd] creating nginx.toml to watch key $confdKey"
echo "keys = [\"$confdKey\"]" >> /etc/confd/conf.d/nginx.toml
echo "[nginx] booting container. ETCD: $ETCD"
# Loop until confd has updated the nginx config
until confd -onetime -node $ETCD -config-file /etc/confd/conf.d/nginx.toml; do
echo "[nginx] waiting for confd to refresh nginx.conf"
sleep 5
done
# Run confd in the background to watch the upstream servers
confd -interval 10 -node $ETCD -config-file /etc/confd/conf.d/nginx.toml &
echo "[nginx] confd is listening for changes on etcd..."
# Start nginx
echo "[nginx] starting nginx service..."
service nginx start
# Tail all nginx log files
tail -f /var/log/nginx/*.log