standardnotes-server/docker/is-available.sh

31 lines
572 B
Bash
Raw Normal View History

#!/bin/bash
WAIT_FOR_URL="$1"
shift
2023-02-07 06:15:20 +00:00
LOGS_PATH="$1"
shift
attempt=0
while [ $attempt -le 120 ]; do
attempt=$(( $attempt + 1 ))
echo "# Waiting for all services to be up (attempt: $attempt) ..."
ping_api_gateway_result=`curl -s $WAIT_FOR_URL | grep "Welcome"`
if [ "$?" -eq "0" ]; then
sleep 2 # for warmup
echo "# All services are up!"
2023-02-07 06:15:20 +00:00
exit 0
break
fi
sleep 2
done
2023-02-07 06:15:20 +00:00
echo "# Failed to wait for all services to be up!"
echo "# Errors:"
tail -n 50 $LOGS_PATH/*.err
2023-02-07 06:15:20 +00:00
echo "# Logs:"
tail -n 50 $LOGS_PATH/*.log
2023-02-07 06:51:53 +00:00
exit 1