Indentation

Indentation for new outer loop
This commit is contained in:
Josh
2015-03-24 23:26:31 -04:00
parent 3b252d43c6
commit 48f76bcfef

View File

@@ -108,83 +108,83 @@ UNCHECKED=1
for (( i=1; i <= RETRIES && UNCHECKED>0 ; i++ )) for (( i=1; i <= RETRIES && UNCHECKED>0 ; i++ ))
do do
UNCHECKED=0 UNCHECKED=0
dokku_log_info1 "Attempt $i/$RETRIES Waiting for $WAIT seconds ..." dokku_log_info1 "Attempt $i/$RETRIES Waiting for $WAIT seconds ..."
sleep $WAIT sleep $WAIT
# -q do not use .curlrc (must come first) # -q do not use .curlrc (must come first)
# --compressed Test compression handled correctly # --compressed Test compression handled correctly
# --fail Fail on server errors (4xx, 5xx) # --fail Fail on server errors (4xx, 5xx)
# --location Follow redirects # --location Follow redirects
CURL_OPTIONS="-q --compressed --fail --location --max-time $TIMEOUT" CURL_OPTIONS="-q --compressed --fail --location --max-time $TIMEOUT"
exec < "$FILENAME" exec < "$FILENAME"
while read CHECK_URL EXPECTED ; do while read CHECK_URL EXPECTED ; do
# Ignore empty lines and lines starting with # # Ignore empty lines and lines starting with #
# shellcheck disable=SC1001 # shellcheck disable=SC1001
[[ -z "$CHECK_URL" || "$CHECK_URL" =~ ^\# ]] && continue [[ -z "$CHECK_URL" || "$CHECK_URL" =~ ^\# ]] && continue
# Ignore variables # Ignore variables
[[ "$CHECK_URL" =~ ^.+= ]] && continue [[ "$CHECK_URL" =~ ^.+= ]] && continue
if [[ "$CHECK_URL" =~ ^https?: ]] ; then if [[ "$CHECK_URL" =~ ^https?: ]] ; then
URL_PROTOCOL=${CHECK_URL%:*} URL_PROTOCOL=${CHECK_URL%:*}
CHECK_URL=${CHECK_URL#*:} CHECK_URL=${CHECK_URL#*:}
else else
URL_PROTOCOL="http" URL_PROTOCOL="http"
fi fi
if [[ "$CHECK_URL" =~ ^//.+ ]] ; then if [[ "$CHECK_URL" =~ ^//.+ ]] ; then
# To test a URL with specific host name, we still make request to localhost, # To test a URL with specific host name, we still make request to localhost,
# but we set Host header to $SEND_HOST. # but we set Host header to $SEND_HOST.
# #
# The pattern is # The pattern is
# //SEND_HOST/PATHNAME # //SEND_HOST/PATHNAME
UNPREFIXED=${CHECK_URL#//} UNPREFIXED=${CHECK_URL#//}
URL_HOSTNAME=${UNPREFIXED%%/*} URL_HOSTNAME=${UNPREFIXED%%/*}
URL_PATHNAME=${UNPREFIXED#$URL_HOSTNAME} URL_PATHNAME=${UNPREFIXED#$URL_HOSTNAME}
HEADERS="-H Host:$URL_HOSTNAME" HEADERS="-H Host:$URL_HOSTNAME"
else else
URL_HOSTNAME=localhost URL_HOSTNAME=localhost
URL_PATHNAME=$CHECK_URL URL_PATHNAME=$CHECK_URL
fi fi
# This URL will show up in the messages # This URL will show up in the messages
LOG_URL="$URL_PROTOCOL://$URL_HOSTNAME$URL_PATHNAME" LOG_URL="$URL_PROTOCOL://$URL_HOSTNAME$URL_PATHNAME"
# And how we formulate the CURL request # And how we formulate the CURL request
CURL_ARGS="$CURL_OPTIONS $URL_PROTOCOL://$DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT$URL_PATHNAME $HEADERS" CURL_ARGS="$CURL_OPTIONS $URL_PROTOCOL://$DOKKU_APP_LISTEN_IP:$DOKKU_APP_LISTEN_PORT$URL_PATHNAME $HEADERS"
dokku_log_verbose "CHECKS expected result:" dokku_log_verbose "CHECKS expected result:"
dokku_log_verbose "$LOG_URL => \"$EXPECTED\"" dokku_log_verbose "$LOG_URL => \"$EXPECTED\""
[[ $DOKKU_TRACE ]] && dokku_log_verbose "$ curl $CURL_ARGS" [[ $DOKKU_TRACE ]] && dokku_log_verbose "$ curl $CURL_ARGS"
# Capture HTTP response or CURL error message # Capture HTTP response or CURL error message
if OUTPUT=$(curl -# $CURL_ARGS 2>&1) ; then if OUTPUT=$(curl -# $CURL_ARGS 2>&1) ; then
# OUTPUT contains the HTTP response # OUTPUT contains the HTTP response
if [[ ! "$OUTPUT" =~ $EXPECTED ]] ; then if [[ ! "$OUTPUT" =~ $EXPECTED ]] ; then
dokku_log_warn "$LOG_URL: expected to but did not find: \"$EXPECTED\"" dokku_log_warn "$LOG_URL: expected to but did not find: \"$EXPECTED\""
#exit 1 #exit 1
UNCHECKED=$(expr $UNCHECKED + 1 )
fi
else
# Failed to connect/no response, OUTPUT contains error message
dokku_log_warn "$OUTPUT"
#exit 2
UNCHECKED=$(expr $UNCHECKED + 1 ) UNCHECKED=$(expr $UNCHECKED + 1 )
fi fi
else done
# Failed to connect/no response, OUTPUT contains error message
dokku_log_warn "$OUTPUT"
#exit 2
UNCHECKED=$(expr $UNCHECKED + 1 )
if [ $UNCHECKED -gt 0 ]; then
dokku_log_warn "Check attempt $i/$RETRIES failed. Retrying..."
continue;
fi fi
done done
if [ $UNCHECKED -gt 0 ]; then
dokku_log_warn "Check attempt $i/$RETRIES failed. Retrying..."
continue;
fi
done
if [ $UNCHECKED -gt 0 ]; then if [ $UNCHECKED -gt 0 ]; then
dokku_log_fail "Could not start due to $UNCHECKED failed checks." dokku_log_fail "Could not start due to $UNCHECKED failed checks."
exit 1 exit 1