Skip to content

Commit

Permalink
Error when service restarts continuously
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdowne committed Aug 4, 2023
1 parent 9816705 commit 8a892f8
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions .github/check-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@

APP_NAME=$1
TIMEOUT=${2:-60} # Default timeout is 60 seconds if not provided
INTERVAL=5

while [ "${TIMEOUT}" -gt 0 ]; do
STATUS=$(docker-compose ps --services --filter "status=running" | grep "${APP_NAME}")
# Give service a chance to start, and also to go into "Restarting" status
sleep "${TIMEOUT}"

if [ -n "$STATUS" ]; then
echo "$APP_NAME is running."
exit 0
fi
STATUS=$(docker-compose ps --services --filter "status=running" | grep "${APP_NAME}")

sleep "${INTERVAL}"
TIMEOUT=$((TIMEOUT - INTERVAL))
done
if [ -n "$STATUS" ]; then
echo "$APP_NAME is running."
exit 0
fi

echo "Timed out waiting for $APP_NAME to start."
echo "$APP_NAME is either not started or restarting"
docker-compose ps | grep "${APP_NAME}"
exit 1

0 comments on commit 8a892f8

Please sign in to comment.