Skip to content

Commit d37ff6b

Browse files
committedJun 18, 2024
Fix localstack readiness check
1 parent a52cd38 commit d37ff6b

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed
 

‎docker/bin/test.sh

+29-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,34 @@ function waitForService()
2727
printf "service is online %s:%s\n" $1 $2
2828
}
2929

30+
function waitForServiceLocalStack()
31+
{
32+
waitForService localstack 4566 $1
33+
34+
ATTEMPTS=0
35+
RESPONSE=''
36+
READY=0
37+
until [ $READY = 1 ]; do
38+
printf "check readiness for service localstack:4566\n"
39+
RESPONSE=$(curl -s http://localstack:4566/_localstack/health)
40+
if [[ $RESPONSE == *'"sns": "running"'* && $RESPONSE == *'"sqs": "running"'* ]]; then
41+
READY=1
42+
fi
43+
((ATTEMPTS++))
44+
if [ $ATTEMPTS -ge $2 ]; then
45+
printf "service is not ready localstack:4566\n"
46+
exit 1
47+
fi
48+
if [ "$FORCE_EXIT" = true ]; then
49+
exit;
50+
fi
51+
52+
sleep 1
53+
done
54+
55+
printf "service is ready localstack:4566\n"
56+
}
57+
3058
trap "FORCE_EXIT=true" SIGTERM SIGINT
3159

3260
waitForService rabbitmq 5672 50
@@ -39,7 +67,7 @@ waitForService gearmand 4730 50
3967
waitForService kafka 9092 50
4068
waitForService mongo 27017 50
4169
waitForService thruway 9090 50
42-
waitForService localstack 4566 50
70+
waitForServiceLocalStack 50 50
4371

4472
php docker/bin/refresh-mysql-database.php || exit 1
4573
php docker/bin/refresh-postgres-database.php || exit 1

0 commit comments

Comments
 (0)