mirror of https://github.com/codevalet/codevalet
Ensure that curl properly fails on bad responses in container-check
Caught my first fat-finger of some code 👏
This commit is contained in:
parent
e1ae017762
commit
efd1ecbbdb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue