blob: fc8f3ca8be48cc07a9dab3b7d901b57af7d18fca [file] [log] [blame]
#!/bin/sh
# Copyright (C) 2019 GerritForge Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
wait_for() {
for i in `seq 30` ; do
curl -f ${ELASTICSEARCH_URL}:${ELASTICSEARCH_PORT}/_cluster/health > /dev/null 2>&1
result=$?
if [ $result -eq 0 ] ; then
if [ $# -gt 0 ] ; then
exec "$@"
fi
exit 0
fi
echo "* Waiting for Elasticsearch ${ELASTICSEARCH_URL}:${ELASTICSEARCH_PORT} ($i/30)"
sleep 2
done
echo "Operation timed out" >&2
exit 1
}
wait_for "$@"