Advertisement
Guest User

Untitled

a guest
May 19th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/bin/bash
  2. set -eu
  3.  
  4. readonly ADMIN_PORT_START=19000
  5.  
  6. # Start sidecars
  7. function start_consul_envoy_sidecar {
  8. local -r sidecar_for="$1"
  9. local -r admin_bind_port="$2"
  10.  
  11. echo "Start consul sidecar for $sidecar_for"
  12. /usr/local/bin/consul connect envoy \
  13. -sidecar-for ${sidecar_for} \
  14. -admin-bind=127.0.0.1:${admin_bind_port} \
  15. -- -l info
  16.  
  17. pids[${i}]=$!
  18. }
  19.  
  20.  
  21. ADMIN_PORT=$ADMIN_PORT_START
  22. # Get list of sidecars
  23. for SVC in $(consul catalog services -node=$HOSTNAME | grep sidecar-proxy)
  24. do
  25. echo $SVC
  26. ADMIN_PORT=$[$ADMIN_PORT +1]
  27.  
  28. svcname="${SVC/-sidecar-proxy/}"
  29.  
  30. start_consul_envoy_sidecar "$svcname" "$ADMIN_PORT" &
  31. done
  32.  
  33.  
  34. # Wait for subprocesses
  35. for job in `jobs -p`
  36. do
  37. echo $job
  38. wait $job
  39. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement