dockerfile/examples/standardnotes/official-src/server-main/docker/is-available.sh

31 lines
572 B
Bash
Raw Permalink Normal View History

2024-03-15 14:52:38 +08:00
#!/bin/bash
WAIT_FOR_URL="$1"
shift
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!"
exit 0
break
fi
sleep 2
done
echo "# Failed to wait for all services to be up!"
echo "# Errors:"
tail -n 50 $LOGS_PATH/*.err
echo "# Logs:"
tail -n 50 $LOGS_PATH/*.log
exit 1