Skip to content

Commit

Permalink
use docker health check for mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunxe committed Oct 20, 2023
1 parent 7dd8e3d commit ae7783f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
6 changes: 4 additions & 2 deletions azure-pipelines/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,15 @@ stages:
displayName: docker run tdengine and checkoutput
- script: |
set -e
docker run -itd --network host --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes mysql:8.1.0
docker run -itd --network host --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes \
--health-cmd='mysqladmin ping -h localhost -uroot' --health-interval=5s --health-timeout=5s --health-retries=20 \
mysql:8.1.0
bash $(System.DefaultWorkingDirectory)/examples/telemetryservice/mysql/checkoutput.sh
displayName: docker run mysql and checkoutput
- script: |
set -e
docker run -itd --network host --name sqlserver -e ACCEPT_EULA=Y -e SA_PASSWORD=Some_Strong_Password \
--health-cmd="/opt/mssql-tools/bin/sqlcmd -U sa -P Some_Strong_Password -Q 'select name from sys.databases'" --health-interval=10s --health-timeout=5s --health-retries=5 \
--health-cmd="/opt/mssql-tools/bin/sqlcmd -U sa -P Some_Strong_Password -Q 'select name from sys.databases'" --health-interval=5s --health-timeout=5s --health-retries=20 \
mcr.microsoft.com/mssql/server:2022-CU7-ubuntu-20.04
bash $(System.DefaultWorkingDirectory)/examples/telemetryservice/sqlserver/checkoutput.sh
displayName: docker run sqlserver and checkoutput
Expand Down
17 changes: 4 additions & 13 deletions examples/telemetryservice/mysql/checkoutput.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
#!/bin/bash
MySQLOutput=2
sleep 3
for i in {1..50}
do
output=$(docker exec mysql mysql -u root -e "Show databases;" 2>&1 | grep 'ERROR' | wc -l)
#echo $output
if [[ $output -eq 0 ]]
then
echo $output
break
elif [[ $i -eq 50 ]]
then
exit 1
fi
echo "Waiting for MySQL to be ready..."
while [[ "$(docker inspect --format='{{.State.Health.Status}}' mysql)" != "healthy" ]]; do
sleep 5
done
echo "MySQL is ready."

# init MySQL Table
docker exec mysql mysql -u root \
Expand Down

0 comments on commit ae7783f

Please sign in to comment.