Skip to content

Commit 25c1703

Browse files
committed
Check for ETSI core context availability.
1 parent 34b60fa commit 25c1703

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

services

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ SCORPIO="http://scorpio:9090/"
1111
ORION="http://orion:1026/version"
1212
STELLIO="http://localhost:8080/actuator/health"
1313
CONTEXT="https://fiware.github.io/tutorials.Step-by-Step/tutorials-context.jsonld"
14+
CORE_CONTEXT="https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld"
1415

1516
dockerCmd="docker compose"
1617
if (( $# == 2 )); then
@@ -80,8 +81,8 @@ waitForStellio () {
8081
done
8182
}
8283

83-
waitForContext () {
84-
echo -e "\n⏳ Waiting for \033[1m@context\033[0m to be available\n"
84+
waitForUserContext () {
85+
echo -e "\n⏳ Waiting for the data models \033[1m@context\033[0m to be available (Smart Supermarket)\n"
8586
getHeartbeat "${CONTEXT}"
8687
while [ "${response}" -eq 000 ]
8788
do
@@ -91,6 +92,17 @@ waitForContext () {
9192
done
9293
}
9394

95+
waitForCoreContext () {
96+
echo -e "\n⏳ Checking availability of \033[1m core @context\033[0m from ETSI\n"
97+
getHeartbeat "${CORE_CONTEXT}"
98+
while [ "${response}" -eq 000 ]
99+
do
100+
echo -e "\n@context HTTP state: ${response} (waiting for 200)"
101+
pause 3
102+
getHeartbeat "${CORE_CONTEXT}"
103+
done
104+
}
105+
94106
waitForMongo () {
95107
echo -e "\n⏳ Waiting for \033[1mMongoDB\033[0m to be available\n"
96108
while ! [ `docker inspect --format='{{.State.Health.Status}}' db-mongo` == "healthy" ]
@@ -101,7 +113,7 @@ waitForMongo () {
101113

102114
loadData () {
103115
echo ""
104-
waitForContext
116+
waitForUserContext
105117
docker run --rm -v $(pwd)/import-data:/import-data \
106118
--network fiware_default \
107119
-e CONTEXT_BROKER=${CONTEXT_BROKER} \
@@ -157,9 +169,10 @@ case "${command}" in
157169
"orion")
158170
export $(cat .env | grep "#" -v)
159171
stoppingContainers
172+
waitForCoreContext
160173
echo -e "Starting containers: \033[1;34mOrion\033[0m, \033[1mTutorial\033[0m and a \033[1mMongoDB\033[0m database."
161174
echo -e "- \033[1;34mOrion\033[0m is the context broker"
162-
echo -e "- \033[1m@context\033[0m is supplied externally"
175+
echo -e "- Data models \033[1m@context\033[0m (Smart Supermarket) is supplied externally"
163176
echo ""
164177
${dockerCmd} -f docker-compose/common.yml -f docker-compose/orion-ld.yml up -d --remove-orphans --renew-anon-volumes
165178
waitForMongo
@@ -172,9 +185,10 @@ case "${command}" in
172185
"scorpio")
173186
export $(cat .env | grep "#" -v)
174187
stoppingContainers
188+
waitForCoreContext
175189
echo -e "Starting containers: \033[1;34mScorpio\033[0m, \033[1mKafka\033[0m, \033[1mZookeeper\033[0m and a \033[1mPostgres\033[0m database, \033[1;36mIoT-Agent\033[0m, \033[1mTutorial\033[0m and a \033[1mMongoDB\033[0m database."
176190
echo -e "- \033[1;34mScorpio\033[0m is the context broker"
177-
echo -e "- \033[1m@context\033[0m is supplied externally"
191+
echo -e "- Data models \033[1m@context\033[0m (Smart Supermarket) is supplied externally"
178192
echo ""
179193
${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio-aaio.yml up -d --remove-orphans --renew-anon-volumes
180194
waitForMongo
@@ -186,9 +200,10 @@ case "${command}" in
186200
"stellio")
187201
export $(cat .env | grep "#" -v)
188202
stoppingContainers
203+
waitForCoreContext
189204
echo -e "Starting containers: \033[1;34mStellio\033[0m, \033[1mKafka\033[0m, \033[1mZookeeper\033[0m, \033[1mNeo4j\033[0m, \033[1mPostgreSQL/TimescaleDB\033[0m, and a linked data \033[1mContext\033[0m."
190205
echo -e "- \033[1;34mStellio\033[0m is the context broker\n"
191-
echo -e "- \033[1m@context\033[0m is supplied externally"
206+
echo -e "- Data models \033[1m@context\033[0m (Smart Supermarket) is supplied externally"
192207
echo ""
193208
${dockerCmd} -f docker-compose/common.yml -f docker-compose/stellio.yml up -d --remove-orphans --renew-anon-volumes
194209
waitForMongo

0 commit comments

Comments
 (0)