Skip to content

Commit

Permalink
Fix: waiting for test container
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyRaga committed Apr 26, 2024
1 parent 0dee497 commit ac70fc1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ services:
MSSQL_SA_PASSWORD: "4YiUmU2YJ8$6eqbSXF8765Ck3"
MSSQL_PID: Developer
healthcheck:
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$${MSSQL_SA_PASSWORD}" -Q "SELECT 1" || exit 1
test: ["CMD", "test", "-f", "/tmp/mssql.ready"]
# test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$${MSSQL_SA_PASSWORD}" -Q "SELECT 1" || exit 1
interval: 5s
timeout: 5s
retries: 5
Expand Down
5 changes: 3 additions & 2 deletions local-env/mssql/initdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ echo "Waiting for SQL Server to start"
while [[ $DBSTATUS -ne 0 ]] && [[ $i -lt $TRIES ]]; do
i=$((i+1))
DBSTATUS=$(/opt/mssql-tools/bin/sqlcmd -h -1 -t 1 -U sa -P $MSSQL_SA_PASSWORD -Q "SET NOCOUNT ON; Select COALESCE(SUM(state), 0) from sys.databases") || DBSTATUS=1
if [ $DBSTATUS -ne 0 ]; then
if [ $DBSTATUS -ne 0 ]; then
sleep 1s
fi
done

sleep 5s
if [ $DBSTATUS -ne 0 ]; then
if [ $DBSTATUS -ne 0 ]; then
echo "SQL Server took more than $TRIES seconds to start up or one or more databases are not in an ONLINE state"
exit 1
fi
Expand All @@ -44,5 +44,6 @@ find /docker-entrypoint-initdb.d -mindepth 2 -type f | sort | while read f; do
echo
done

touch /tmp/mssql.ready
echo "SQL Server is running"
sleep infinity

0 comments on commit ac70fc1

Please sign in to comment.