Spaces:
Sleeping
Sleeping
File size: 1,629 Bytes
b110593 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#!/bin/bash
set -euo pipefail
# This scripts starts a Weaviate server with the test scheme and waits until weaviate is up and running.
function build() {
echo "Pull images..."
surpress_on_success docker pull golang:1.19-alpine
echo "Build containers (this will take the longest)..."
GIT_HASH=$(git rev-parse --short HEAD)
docker compose -f "$1" build --build-arg GITHASH="$GIT_HASH" --build-arg EXTRA_BUILD_ARGS="-race" "$2"
echo "Start up docker compose setup..."
}
function wait(){
MAX_WAIT_SECONDS=60
ALREADY_WAITING=0
while true; do
if curl -s http://localhost:8080 > /dev/null; then
break
else
if [ $? -eq 7 ]; then
echo "Weaviate is not up yet. (waited for ${ALREADY_WAITING}s)"
echo "Weaviate:"
docker compose -f "$1" logs weaviate
if [ $ALREADY_WAITING -gt $MAX_WAIT_SECONDS ]; then
echo "Weaviate did not start up in $MAX_WAIT_SECONDS."
docker compose -f "$1" logs
exit 1
else
sleep 2
let ALREADY_WAITING=$ALREADY_WAITING+2
fi
fi
fi
done
echo "Weaviate is up and running!"
}
surpress_on_success() {
out="$("${@}" 2>&1)" || { echo_red "FAILED!"; echo "$out"; return 1; }
echo "Done!"
}
function echo_red() {
red='\033[0;31m'
nc='\033[0m'
echo -e "${red}${*}${nc}"
}
build "$@" docker-compose-test.yml weaviate
surpress_on_success docker compose -f docker-compose-test.yml up --force-recreate -d weaviate contextionary
wait "$@" docker-compose-test.yml
|