Skip to content

Commit

Permalink
can't go below 10s ttl, but you can sleep for 1 second
Browse files Browse the repository at this point in the history
  • Loading branch information
trilom committed Nov 8, 2021
1 parent 7f5936c commit c2f5075
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions consul.sh
Original file line number Diff line number Diff line change
@@ -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}"
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |

0 comments on commit c2f5075

Please sign in to comment.