Skip to content

Instantly share code, notes, and snippets.

@sl1pm4t
Last active May 8, 2019 22:30
Show Gist options
  • Save sl1pm4t/b74a43033226148b1aa6fb08a0afa1b2 to your computer and use it in GitHub Desktop.
Save sl1pm4t/b74a43033226148b1aa6fb08a0afa1b2 to your computer and use it in GitHub Desktop.

Revisions

  1. sl1pm4t revised this gist May 8, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion start-consul-sidecars.sh
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,7 @@ ADMIN_PORT=$ADMIN_PORT_START
    # Get list of sidecars
    for SVC in $(consul catalog services -node=$HOSTNAME | grep sidecar-proxy)
    do
    echo $SVC
    echo $SVC
    ADMIN_PORT=$[$ADMIN_PORT +1]

    svcname="${SVC/-sidecar-proxy/}"
  2. sl1pm4t created this gist May 8, 2019.
    39 changes: 39 additions & 0 deletions start-consul-sidecars.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    #!/bin/bash
    set -eu

    readonly ADMIN_PORT_START=19000

    # Start sidecars
    function start_consul_envoy_sidecar {
    local -r sidecar_for="$1"
    local -r admin_bind_port="$2"

    echo "Start consul sidecar for $sidecar_for"
    /usr/local/bin/consul connect envoy \
    -sidecar-for ${sidecar_for} \
    -admin-bind=127.0.0.1:${admin_bind_port} \
    -- -l info

    pids[${i}]=$!
    }


    ADMIN_PORT=$ADMIN_PORT_START
    # Get list of sidecars
    for SVC in $(consul catalog services -node=$HOSTNAME | grep sidecar-proxy)
    do
    echo $SVC
    ADMIN_PORT=$[$ADMIN_PORT +1]

    svcname="${SVC/-sidecar-proxy/}"

    start_consul_envoy_sidecar "$svcname" "$ADMIN_PORT" &
    done


    # Wait for subprocesses
    for job in `jobs -p`
    do
    echo $job
    wait $job
    done