Skip to content

Commit

Permalink
Update Scorpio
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Jan 3, 2024
1 parent b1181da commit f6049db
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 54 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ STELLIO_DOCKER_TAG=2.10.2
STELLIO_PORT=8080
STELLIO_TIMESCALE_POSTGIS=14-2.11.1-3.3

# Curl variables
CURL_VERSION=8.4.0

# MongoDB variables
MONGO_DB_PORT=27017
Expand Down
55 changes: 12 additions & 43 deletions docker-compose/scorpio-aaio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,20 @@
# see: https://github.com/FIWARE/helm-charts/
#
version: "3.9"

services:
zookeeper:
labels:
org.fiware: 'tutorial'
image: zookeeper
hostname: zookeeper
container_name: zookeeper
networks:
- default
ports:
- "2181"
logging:
driver: none
kafka:
# Scorpio is the context broker
scorpio:
labels:
org.fiware: 'tutorial'
image: bitnami/kafka
hostname: kafka
container_name: kafka
image: quay.io/fiware/scorpio:java-${SCORPIO_VERSION}
hostname: scorpio
container_name: fiware-scorpio
networks:
- default
ports:
- "9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_PORT: 9092
KAFKA_LOG_RETENTION_MS: 10000
KAFKA_LOG_RETENTION_CHECK_INTERVAL_MS: 5000
ALLOW_PLAINTEXT_LISTENER: "yes"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- "${EXPOSED_PORT}:${SCORPIO_PORT}"
depends_on:
- zookeeper
logging:
driver: none
- postgres
postgres:
labels:
org.fiware: 'tutorial'
Expand All @@ -70,16 +47,8 @@ services:
POSTGRES_DB: ngb
logging:
driver: none
scorpio:
labels:
org.fiware: 'tutorial'
image: scorpiobroker/all-in-one-runner:java-kafka-${SCORPIO_VERSION}
hostname: scorpio
container_name: fiware-scorpio
networks:
- default
ports:
- ${EXPOSED_PORT:-1026}:${SCORPIO_PORT:-9090}
depends_on:
- postgres
- kafka
volumes:
- postgres-db:/var/lib/postgresql/data

volumes:
postgres-db: ~
22 changes: 11 additions & 11 deletions services
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pause(){
}

getHeartbeat(){
eval "response=$(docker run --network fiware_default --rm quay.io/curl/curl -s -o /dev/null -w "%{http_code}" "$1")"
eval "response=$(docker run --network fiware_default --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w "%{http_code}" "$1")"
}

waitForOrion () {
Expand Down Expand Up @@ -75,22 +75,22 @@ waitForScorpio () {
while [ "${response}" -eq 000 ]
do
echo -e "Context Broker HTTP state: ${response} (waiting for 500)"
pause 60
pause 6
getHeartbeat "${SCORPIO}"
done
}

waitForStellio () {
echo -e "\n⏳ Waiting for \033[1;34mStellio\033[0m to respond\n"
waitSeconds=30
while [ `docker run --network fiware_default --rm quay.io/curl/curl -s -o /dev/null -w %{http_code} 'http://stellio:8080/ngsi-ld/v1/entities/?type=X'` -eq 000 ]
while [ `docker run --network fiware_default --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w %{http_code} 'http://stellio:8080/ngsi-ld/v1/entities/?type=X'` -eq 000 ]
do
echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:8080/ngsi-ld/v1/entities/?type=X'` " (waiting for 500)"
echo -e "Waiting for ${waitSeconds} seconds ..."
sleep ${waitSeconds}
done
echo -e "\n⏳ Waiting for all \033[1;34mStellio\033[0m services to be available\n"
while [ `docker run --network fiware_default --rm quay.io/curl/curl -s -o /dev/null -w %{http_code} 'http://stellio:8080/ngsi-ld/v1/entities/?type=X'` -eq 500 ]
while [ `docker run --network fiware_default --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w %{http_code} 'http://stellio:8080/ngsi-ld/v1/entities/?type=X'` -eq 500 ]
do
echo -e "Context Broker HTTP state: " `curl -s -o /dev/null -w %{http_code} 'http://localhost:8080/ngsi-ld/v1/entities/?type=X'` " (waiting for 200)"
echo -e "Waiting for ${waitSeconds} seconds ..."
Expand All @@ -100,12 +100,12 @@ waitForStellio () {

waitForCoreContext () {
echo -e "\n⏳ Checking availability of \033[1m core @context\033[0m from ETSI\n"
eval "response=$(docker run --rm quay.io/curl/curl -s -o /dev/null -w "%{http_code}" "$CORE_CONTEXT")"
eval "response=$(docker run --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w "%{http_code}" "$CORE_CONTEXT")"
while [ "${response}" -eq 000 ]
do
echo -e "\n@context HTTP state: ${response} (waiting for 200)"
pause 3
eval "response=$(docker run --rm quay.io/curl/curl -s -o /dev/null -w "%{http_code}" "$CORE_CONTEXT")"
eval "response=$(docker run --rm quay.io/curl/curl:${CURL_VERSION} -s -o /dev/null -w "%{http_code}" "$CORE_CONTEXT")"
done
}

Expand Down Expand Up @@ -148,7 +148,7 @@ loadData () {
--network fiware_default \
-e CONTEXT_BROKER=${CONTEXT_BROKER} \
-e TUTORIAL_DATA_MODELS_CONTEXT="http://context/ngsi-context.jsonld" \
--entrypoint /bin/ash quay.io/curl/curl /import-data
--entrypoint /bin/ash quay.io/curl/curl:${CURL_VERSION} /import-data
echo ""
}

Expand Down Expand Up @@ -222,11 +222,11 @@ case "${command}" in
export $(cat .env | grep "#" -v)
stoppingContainers
waitForCoreContext
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."
echo -e "Starting containers: \033[1;34mScorpio\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."
echo -e "- \033[1;34mScorpio\033[0m is the context broker"
echo -e "- Data models \033[1m@context\033[0m (Smart Farm) is supplied externally"
echo ""
${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio-aaio.yml up -d --remove-orphans --renew-anon-volumes
${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio.yml up -d --remove-orphans --renew-anon-volumes
displayServices "scorpio|fiware"
waitForMongo
addDatabaseIndex
Expand Down Expand Up @@ -262,8 +262,8 @@ case "${command}" in
"create")
export $(cat .env | grep "#" -v)
echo "Pulling Docker images"
docker pull -q quay.io/curl/curl
${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio-aaio.yml -f docker-compose/orion-ld.yml -f docker-compose/stellio.yml pull
docker pull -q quay.io/curl/curl:${CURL_VERSION}
${dockerCmd} -f docker-compose/common.yml -f docker-compose/scorpio.yml -f docker-compose/orion-ld.yml -f docker-compose/stellio.yml pull
;;
*)
echo "Command not Found."
Expand Down

0 comments on commit f6049db

Please sign in to comment.