-
Notifications
You must be signed in to change notification settings - Fork 0
/
nutcracker_run.sh
executable file
·64 lines (49 loc) · 1.14 KB
/
nutcracker_run.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
#!/bin/bash
OIFS=$IFS
IFS=";"
ratelimiterservers=( $TWEMPROXY_RATELIMITER_SERVER )
cacheservers=( $TWEMPROXY_CACHE_SERVER )
twemproxyconfig="$(cat <<-EndOfNutCrackerYML
ratelimiter:
auto_eject_hosts: true
distribution: ketama
hash: fnv1a_64
listen: 127.0.0.1:22121
redis: true
server_failure_limit: 2
server_retry_timeout: 2000
timeout: 1000
servers:
EndOfNutCrackerYML
)"
for ((i=0; i<${#ratelimiterservers[@]}; ++i));
do
twemproxyconfig="$twemproxyconfig$(cat <<-EndOfNutCrackerYML
- ${ratelimiterservers[$i]}
EndOfNutCrackerYML
)"
done
twemproxyconfig="$twemproxyconfig$(cat <<-EndOfNutCrackerYML
cache:
auto_eject_hosts: true
distribution: ketama
hash: fnv1a_64
listen: 127.0.0.1:22122
redis: true
server_failure_limit: 2
server_retry_timeout: 2000
timeout: 1000
servers:
EndOfNutCrackerYML
)"
for ((i=0; i<${#cacheservers[@]}; ++i));
do
twemproxyconfig="$twemproxyconfig$(cat <<-EndOfNutCrackerYML
- ${cacheservers[$i]}
EndOfNutCrackerYML
)"
done
IFS=$OIFS
echo "$twemproxyconfig" > nutcracker.yml
# Pass on any arguments to nutcracker
/usr/local/sbin/nutcracker -c nutcracker.yml "$@"