From 1f1c390f50c8dedba7e0dbb3130576e63a766fa2 Mon Sep 17 00:00:00 2001 From: Kai Davenport Date: Wed, 3 Sep 2014 03:24:20 -0700 Subject: [PATCH 1/2] allow third segment to join/advertise option that indicates client mode (e.g. 10.0.0.1::10.0.0.2::client) this drops the -server flag when booting consul --- start | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/start b/start index 228753a38e31..b935cd98cc30 100755 --- a/start +++ b/start @@ -7,15 +7,20 @@ cmd-run() { local ip_def="$1"; shift local args="$@" - declare external_ip join_ip bridge_ip run_mode + declare external_ip join_ip bridge_ip run_mode client_flag server_flag + + IFS=':' read external_ip join_ip client_flag <<< "${ip_def//::/:}" - IFS=':' read external_ip join_ip <<< "${ip_def/::/:}" if [[ -z "$join_ip" ]]; then run_mode="-bootstrap-expect $EXPECT" else run_mode="-join $join_ip" fi + if [[ -z "$client_flag" ]]; then + server_flag="-server" + fi + bridge_ip="$(ip ro | awk '/^default/{print $3}')" cat < Date: Wed, 3 Sep 2014 03:44:21 -0700 Subject: [PATCH 2/2] Example of using the ::client flag for the runner command --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aea4d9a65816..112f65d7949a 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ That's it! Once this last node connects, it will bootstrap into a cluster. You n #### Runner command -Since the `docker run` command to start in production is so long, a command is available to generate this for you. Running with `cmd:run [::] [docker-run-args...]` will output an opinionated, but customizable `docker run` command you can run in a subshell. For example: +Since the `docker run` command to start in production is so long, a command is available to generate this for you. Running with `cmd:run [::[::]] [docker-run-args...]` will output an opinionated, but customizable `docker run` command you can run in a subshell. For example: $ docker run --rm progrium/consul cmd:run 10.0.1.1 -d @@ -154,6 +154,16 @@ To use this convenience, you simply wrap the `cmd:run` output in a subshell. Run $ $(docker run --rm progrium/consul cmd:run 127.0.0.1 -it) +##### Client flag + +Client nodes allow you to keep growing your cluster without impacting the performance of the underlying gossip protocol (they proxy requests to one of the server nodes and so are stateless). + +To boot a client node using the runner command, append the string `::client` onto the `::` argument. For example: + + $ docker run --rm progrium/consul cmd:run 10.0.1.4::10.0.1.2::client -d + +Would create the same output as above but without the `-server` consul argument. + #### Health checking with Docker Consul lets you specify a shell script to run for health checks, similar to Nagios. As a container, those scripts run inside this container environment which is a minimal Busybox environment with bash and curl. For some, this is fairly limiting, so I've added some built-in convenience scripts to properly do health checking in a Docker system.