-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathtoxiproxy.sh
More file actions
executable file
·33 lines (27 loc) · 873 Bytes
/
toxiproxy.sh
File metadata and controls
executable file
·33 lines (27 loc) · 873 Bytes
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
#!/bin/sh
set -eu -o pipefail
### INSTALLATION
# https://github.com/Shopify/toxiproxy
# brew tap shopify/shopify
# brew install toxiproxy
### RUNNING
# ./toxiproxy.sh
# ./toxiproxy.sh 80 8080 100
# toxiproxy-cli list
# killall toxiproxy-server
# toxiproxy-cli toxic help
# toxiproxy-cli toxic update --toxicName hf_latency_toxic --attribute latency=500 hf_dev_proxy
set -x
PORT=${1:-80}
UPSTREAM_PORT=${2:-8080}
LATENCY=${3:-100}
log_level=fatal # even 'error' is too spammy
set +x
LOG_LEVEL=${log_level} toxiproxy-server &
echo "waiting for toxiproxy to be ready:"
while ! nc -z localhost 8474; do # toxiproxy control port
printf .
sleep 1
done
toxiproxy-cli create --listen 0.0.0.0:${PORT} --upstream localhost:${UPSTREAM_PORT} hf_dev_proxy && \
toxiproxy-cli toxic add --toxicName hf_latency_toxic --type latency --attribute latency=${LATENCY} hf_dev_proxy