Skip to content

Commit

Permalink
Display logs and exit the container upon encountering an error.
Browse files Browse the repository at this point in the history
  • Loading branch information
levisingularity committed Feb 28, 2024
1 parent c3146e8 commit dd16358
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion scripts/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

set -e

OPENFAAS_CONTAINER_MAX_ATTEMPS=5
OPENFAAS_CONTAINER_ATTEMPS=0

OPENFAAS_CONTAINER="openfaas"

QUERY_ENGINE_SERVICE="query-engine"
Expand All @@ -19,8 +22,25 @@ if ! docker ps --format '{{.Names}}' | grep -q "$OPENFAAS_CONTAINER"; then
unset REMOTE
fi

while ! docker exec $OPENFAAS_CONTAINER pgrep -f $QUERY_ENGINE_SERVICE >/dev/null; do
while ! docker exec "$OPENFAAS_CONTAINER" pgrep -f "$QUERY_ENGINE_SERVICE" >/dev/null; do
OPENFAAS_EXIT_CODE=$(docker inspect --format='{{.State.ExitCode}}' "$OPENFAAS_CONTAINER")

if [ "$OPENFAAS_CONTAINER_ATTEMPS" -gt "$OPENFAAS_CONTAINER_MAX_ATTEMPS" ]; then
echo "Exceeded maximum attempts to start the container $OPENFAAS_CONTAINER"
docker logs "$OPENFAAS_CONTAINER"
exit 1
fi

if [ "$OPENFAAS_EXIT_CODE" -gt 0 ]; then
echo "The container $OPENFAAS_CONTAINER exited with status code $OPENFAAS_EXIT_CODE"
docker logs "$OPENFAAS_CONTAINER"
exit 1
fi

echo "Waiting for $QUERY_ENGINE_SERVICE in container $OPENFAAS_CONTAINER to start..."

OPENFAAS_CONTAINER_ATTEMPS=$(($OPENFAAS_CONTAINER_ATTEMPS + 1))

sleep 10
done

Expand Down

0 comments on commit dd16358

Please sign in to comment.