Ensure that curl properly fails on bad responses in container-check

Caught my first fat-finger of some code 👏
This commit is contained in:
R. Tyler Croy 2018-01-02 14:57:51 -08:00
parent e1ae017762
commit efd1ecbbdb
No known key found for this signature in database
GPG Key ID: 1426C7DC3F51E16F
1 changed files with 12 additions and 5 deletions

View File

@ -12,24 +12,31 @@ function terminate {
trap terminate EXIT
docker run --detach -p ${PORT}:${PORT} \
docker run --detach -e RACK_ENV=production \
-p ${PORT}:${PORT} \
--name ${NAME} \
${IMAGE_NAME}:latest \
for i in $(seq 1 10); do
echo ">> Attempt #${i} to reach ${URL}"
curl -sI ${URL} 2>&1 > /dev/null
if [ $? -ne 0 ]; then
sleep 1
curl --silent --fail ${URL} 2>&1 > /dev/null
STATUS=$?
if [ $STATUS -eq 22 ]; then
echo "----> :( Container returned a bad response"
break;
elif [ $STATUS -ne 0 ]; then
sleep 1;
else
echo '----> :) The app returned a 200'
exit 0
exit 0;
fi;
sleep 1
done;
echo "----> :( Failed to reach the container"
docker logs ${NAME}
docker ps
# If we get to here without having bailed out, something is wrong
exit 1