github.com/greenboxal/deis@v1.12.1/contrib/aws/check (about)

     1  #!/usr/bin/env bash
     2  
     3  set -eo pipefail -o nounset
     4  
     5  function check-elb-service {
     6    local elb_name="${1}"
     7  
     8    ATTEMPTS=45
     9    SLEEPTIME=10
    10    COUNTER=1
    11    IN_SERVICE=0
    12    until [ $IN_SERVICE -ge 1 ]; do
    13      if [ $COUNTER -gt $ATTEMPTS ]; then exit 1; fi  # timeout after 7 1/2 minutes
    14      if [ $COUNTER -ne 1 ]; then sleep $SLEEPTIME; fi
    15      rigger-log "Waiting for ELB (${elb_name}) to see an instance in InService..."
    16      IN_SERVICE=$(aws elb describe-instance-health \
    17                           --load-balancer-name "${elb_name}" \
    18                           --query 'length(InstanceStates[?State==`InService`])')
    19    done
    20  }
    21  
    22  check-elb-service "${ELB_NAME}"