-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice-discovery-client-example.sh
executable file
·67 lines (46 loc) · 1.22 KB
/
service-discovery-client-example.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
#!/usr/bin/env bash
#######################
# Example Client #
#######################
set -e
pidfile="/tmp/service-discovery-client"
# lock the script
exec 200>$pidfile
flock -n 200 || ( echo "service discovery client is already running. Aborting . . " && exit 1 )
pid=$$
echo $pid 1>&200
populate_env_vars()
{
#Populate /etc/environment if it was modified
for line in $( cat /etc/environment ) ; do
if [ "$line" != "" ]; then
export $line || true
fi
done
}
ENV_TYPE=testing
if [ "$APP_ENV" = "prod" ]
then
ENV_TYPE=prod
fi
DIR=/root/services-info
FILE=services-info-${ENV_TYPE}.json
#Use --skip-existing parameter to skip overwriting file
FORCE="--force"
if [ "$1" == "--skip-existing" ]; then
FORCE="--skip-existing"
fi
mkdir -p ${DIR}
#http://s3tools.org/download
s3cmd get ${FORCE} s3://services.store/${FILE}.des3 ${DIR}/${FILE}.des3
#decrypt file
/root/endec_all -o /tmp -d ${DIR}/${FILE}.des3
#The end file will be called services-info.json regardless the ENV
mv /tmp/${FILE} ${DIR}/services-info.json
populate_env_vars
#load custom client
php custom-client.php
if [[ "$1" != "--skip-existing" ]]; then
populate_env_vars
sudo service nginx reload
fi