Last active
September 11, 2017 18:45
-
-
Save spektom/92c4d30d882a0540836fa5c04904ec20 to your computer and use it in GitHub Desktop.
Ephemeral nodes in Consul
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 -x | |
if [ -z "$1" ]; then | |
echo "USAGE: $0 <session ID>" | |
exit 1 | |
fi | |
read -d '' data <<EOF | |
{ | |
} | |
EOF | |
curl -sS --request PUT --data "${data}" "http://localhost:8500/v1/kv/my-key?acquire=$1" |
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 -x | |
read -d '' data <<EOF | |
{ | |
"LockDelay": "15s", | |
"Name": "my-service", | |
"Checks": [], | |
"Behavior": "delete", | |
"TTL": "10s" | |
} | |
EOF | |
session_id=$(curl -sS --request PUT --data "${data}" http://localhost:8500/v1/session/create | jq .ID -r) | |
while true; do | |
sleep 5 | |
curl -sS --request PUT http://localhost:8500/v1/session/renew/${session_id} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment