Files
SearchServices/e2e-test/helpers/wait-service-to-start.sh
Domenico Sibilio e14c44b1a5 ACS-2563 Disallow alfresco.secureComms=none
(cherry picked from commit e26c7f08601e15fcde0ba51df90212d69b9800e1)
2022-03-02 13:36:52 +01:00

37 lines
1016 B
Bash
Executable File

#!/usr/bin/env bash
set -e # exit if commands fails
set -x # trace what gets exe
WAIT_INTERVAL=1
COUNTER=0
TIMEOUT=2000
t0=`date +%s`
declare -a endpoints=("${1:-http://localhost:8081/alfresco/}" "${1:-http://localhost:8083/solr/}")
for endpoint in "${endpoints[@]}"
do
echo "Waiting for Service to start using endpoint: ${endpoint}"
additional_args=()
if [[ $endpoint == *"solr"* ]]; then
additional_args+=(-H "X-Alfresco-Search-Secret: secret")
fi
until [[ "$(curl --output /dev/null -w ''%{http_code}'' "${additional_args[@]}" --silent --head --fail ${endpoint})" == 200 ]] || [ "$COUNTER" -eq "$TIMEOUT" ]; do
printf '.'
sleep $WAIT_INTERVAL
COUNTER=$(($COUNTER+$WAIT_INTERVAL))
done
if (("$COUNTER" < "$TIMEOUT")) ; then
t1=`date +%s`
delta=$((($t1 - $t0)/60))
echo "Service ${endpoint} Started in $delta minutes"
else
echo "Service ${endpoint} could not start in time."
echo "Waited $COUNTER seconds"
exit 1
fi
done