Skip to content

Commit 30f876b

Browse files
committed
integrate db startup health check into service definition
See: microsoft/mssql-docker#133
1 parent 31ce58f commit 30f876b

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,19 @@ jobs:
4141
MSSQL_SA_PASSWORD: ${{ env.SAPW }}
4242
MSSQL_PID: Developer
4343
MSSQL_COLLATION: SQL_Latin1_General_CP1_CI_AS
44-
options:
45-
name: mssql
44+
options: >-
45+
--name mssql
46+
--health-cmd "/opt/mssql-tools/bin/sqlcmd -b -o /dev/null -U sa -P ${MSSQL_SA_PASSWORD} -Q 'SELECT 1;'"
47+
--health-interval 60s
48+
--health-timeout 30s
49+
--health-start-period 20s
50+
--health-retries 11
4651
ports:
4752
- 1433:1433
4853

4954
steps:
5055
- name: show Docker processes
5156
run: docker ps --all
52-
- name: check that database instance is ready
53-
env:
54-
TMOUT: 60
55-
run: |
56-
for i in `seq ${TMOUT}`; do
57-
sleep 1
58-
docker logs mssql \
59-
| fgrep -n 'SQL Server is now ready for client connections.'
60-
if [ 0 -eq $? ]; then
61-
echo "$(date -u '+%F %T.%N %Z') Info: Successfully detected SQL Server readiness after ${i} seconds"
62-
exit 0
63-
fi
64-
done
65-
echo "$(date -u '+%F %T.%N %Z') Warning: Could not detect SQL Server ready status after ${TMOUT} seconds."
6657
- name: test connect to database as SA
6758
env:
6859
SQLCMDDBNAME: master

0 commit comments

Comments
 (0)