From c2f5075ed8476fa59d18808d39e02c0f1d9297d4 Mon Sep 17 00:00:00 2001 From: Bryan Killian Date: Sun, 7 Nov 2021 22:52:24 -0500 Subject: [PATCH] can't go below 10s ttl, but you can sleep for 1 second --- consul.sh | 4 ++-- readme.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/consul.sh b/consul.sh index 78feb9a..e0f44ca 100644 --- a/consul.sh +++ b/consul.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -set -x +#set -x env # your CONSUL url default is "http://localhost:8500" CONSUL_HTTP_ADDR="${CONSUL_HTTP_ADDR:=http://localhost:8500}" @@ -37,7 +37,7 @@ function create_key () { "404") echo "NO" echo -n "creating key..." - CREATE_KEY_RESPONSE_CODE=$(curl -o /dev/null -w "%{http_code}" -X PUT $CONSUL_HTTP_ADDR/v1/kv$CONSUL_LEADER_KEY) + CREATE_KEY_RESPONSE_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X PUT $CONSUL_HTTP_ADDR/v1/kv$CONSUL_LEADER_KEY) [ "$CREATE_KEY_RESPONSE_CODE" = "200" ] && echo "CREATED" || exit 1 ;; "200") diff --git a/readme.md b/readme.md index 987bf79..c28b7a5 100644 --- a/readme.md +++ b/readme.md @@ -30,6 +30,6 @@ Basically you run this as a sidecar container to manage who is a leader in a gro | CONSUL_LEADER_SERVICE_NAME | consul-leader | Changes the key root (if not explcit) and session label. | | CONSUL_LEADER_KEY | /consul-leader/lock **OR** /consul-leader/CONSUL_LEADER_SERVICE_NAME/lock | Explicitly set the KV key to lock on. | | CONSUL_LEADER_PRIMARY_LABEL | primary | Label the leader this tag. | -| CONSUL_LEADER_TTL | 15s | TTL of session. Must more more than sleep or will break. | +| CONSUL_LEADER_TTL | 15s | TTL of session. Must more more than sleep or will break. `10s-24h0m0s` | | CONSUL_LEADER_SLEEP | 10 | Sleep period for renewing TTL. | | CONSUL_LEADER_LOCKDELAY | 0s | [Lock delay of key.](https://www.consul.io/docs/dynamic-app-config/sessions#session-design) |