Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -eu
- readonly ADMIN_PORT_START=19000
- # Start sidecars
- function start_consul_envoy_sidecar {
- local -r sidecar_for="$1"
- local -r admin_bind_port="$2"
- echo "Start consul sidecar for $sidecar_for"
- /usr/local/bin/consul connect envoy \
- -sidecar-for ${sidecar_for} \
- -admin-bind=127.0.0.1:${admin_bind_port} \
- -- -l info
- pids[${i}]=$!
- }
- ADMIN_PORT=$ADMIN_PORT_START
- # Get list of sidecars
- for SVC in $(consul catalog services -node=$HOSTNAME | grep sidecar-proxy)
- do
- echo $SVC
- ADMIN_PORT=$[$ADMIN_PORT +1]
- svcname="${SVC/-sidecar-proxy/}"
- start_consul_envoy_sidecar "$svcname" "$ADMIN_PORT" &
- done
- # Wait for subprocesses
- for job in `jobs -p`
- do
- echo $job
- wait $job
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement