Skip to content

Commit

Permalink
add retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunxe committed Sep 18, 2023
1 parent d8e1b6c commit 673be0d
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions examples/telemetryservice/sqlserver/checkoutput.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
#!bin/bash
SQLServerOutput=2
sleep 6
for i in {1..50}
do
output=$(docker exec sqlserver /opt/mssql-tools/bin/sqlcmd \
-S localhost -U sa -P Some_Strong_Password \
-Q "select name from sys.databases" | grep 'Error' | wc -l)
echo $output
if [[ $output -eq 0 ]]
then
MAX_RETRIES=5
for retry in $(seq 1 $MAX_RETRIES); do
echo "Attempt $retry of $MAX_RETRIES"

for i in {1..50}; do
output=$(docker exec sqlserver /opt/mssql-tools/bin/sqlcmd \
-S localhost -U sa -P Some_Strong_Password \
-Q "select name from sys.databases" | grep 'Error' | wc -l)
echo "Output: $output"

if [[ $output -eq 0 ]]; then
echo "Database connection successful"
break
elif [[ $i -eq 50 ]]; then
echo "Max retries reached. Exiting script."
exit 1
else
sleep 5
fi
done

if [[ $output -eq 0 ]]; then
break
elif [[ $i -eq 50 ]]
then
exit 1
fi
done

Expand Down

0 comments on commit 673be0d

Please sign in to comment.