Last active
July 23, 2017 09:18
-
-
Save ianblenke/e11448242d76f2e818ec to your computer and use it in GitHub Desktop.
Consul blocking queries using X-Consul-Index via curl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
while true; do | |
INDEX_FILE="$(mktemp -t consul_index_XXX)" | |
CONSUL_INDEX=$( | |
curl -isL -H "X-Auth-Token: $CONSUL_TOKEN" \ | |
-H 'X-Consul-Index: 1' \ | |
--cacert /etc/consul/ssl/ca.cert "https://consul.service.consul:8500/v1/event/list?index=$CONSUL_INDEX&wait=1m" | \ | |
tee "$INDEX_FILE" | \ | |
grep X-Consul-Index | \ | |
sed -e 's/^.*: *//' | \ | |
tr -d '\015') | |
# echo "X-Consul-Index: ${CONSUL_INDEX}" | |
cat $INDEX_FILE | tr -d '\015' | sed -e '1,/^$/d' | jq '.[-1]' | |
rm -f "$INDEX_FILE" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment