graphql-engine/docker-compose/sqlserver-init/init.sh
Daniel Harvey f4f4221d04 tests: Docker Compose healthchecks
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6282
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
Co-authored-by: Samir Talwar <47582+SamirTalwar@users.noreply.github.com>
GitOrigin-RevId: c2b1f958364ce5e1ef704fa1275d18ac810ca35b
2022-10-17 13:20:31 +00:00

28 lines
543 B
Bash
Executable File

#!/bin/bash
set -e
set -u
set -o pipefail
SERVER_PORT="${1:-1433}"
SLEEP=5
MAX_ATTEMPTS=50
if [[ -z "${SERVER_HOST-}" ]]; then
echo 'The server host must be set.'
fi
echo "Initializing ${SERVER_HOST}:${SERVER_PORT}..."
sleep "${SLEEP}"
for i in $(seq 1 $MAX_ATTEMPTS); do
echo "Attempt #${i} / ${MAX_ATTEMPTS}:"
if /opt/mssql-tools/bin/sqlcmd -S "${SERVER_HOST},${SERVER_PORT}" -U SA -P "DockerComposePassword!" -i /init.sql; then
break
fi
echo "Waiting ${SLEEP} seconds..."
sleep "${SLEEP}"
done
echo Finished attempts.