Skip to content

Commit

Permalink
Merge pull request #2 from jembi/PLAT-175-await-helper-logic-update
Browse files Browse the repository at this point in the history
Clean code
  • Loading branch information
MattyJ007 authored Apr 1, 2022
2 parents 6bd9578 + 59ec79d commit 0d4dc6e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions awaitHelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

START_TIME=$(date +%s)

Warned="false"
echo "Waiting for $@"
until [ $(curl --write-out "%{http_code}\n" --silent --output /dev/null "$@") = "200" ]; do
currentTime=$(date +%s)
if [ "$(($currentTime - $START_TIME))" -ge 60 ] && [ $Warned = "false" ]; then
TimeDiff=$(($(date +%s) - $START_TIME))
if [ "$TimeDiff" -ge 60 ] && [ "$TimeDiff" -lt 61 ]; then
echo "Warning: Waited 60s with no response. This is taking longer than it should..."
Warned="true"
elif [ "$(($currentTime - $START_TIME))" -ge 120 ] && [ $Warned = "true" ]; then
echo "Fatal: Waited 130s with no response. Exiting..."
elif [ "$TimeDiff" -ge 120 ]; then
echo "Fatal: Waited 120s with no response. Exiting..."
exit 1
fi

Expand Down

0 comments on commit 0d4dc6e

Please sign in to comment.