Skip to content

Commit

Permalink
Update to MongoDB 6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-fox committed Aug 30, 2024
1 parent 1e1e140 commit 715580f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CURL_VERSION=8.4.0

# MongoDB variables
MONGO_DB_PORT=27017
MONGO_DB_VERSION=4.4
MONGO_DB_VERSION=6.0

# IoT Agent Ultralight Variables
ULTRALIGHT_VERSION=3.3.0-distroless
Expand Down
4 changes: 1 addition & 3 deletions docker-compose/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ services:
- mongo-db:/data/db
- mongo-config:/data/configdb
healthcheck:
test: |
host=`hostname --ip-address || echo '127.0.0.1'`;
mongo --quiet $host/test --eval 'quit(db.runCommand({ ping: 1 }).ok ? 0 : 2)' && echo 0 || echo 1
test: ["CMD","mongosh", "localhost:27017/test", "--quiet"]
interval: 5s

# IoT-Agent is configured for the UltraLight Protocol
Expand Down
2 changes: 1 addition & 1 deletion docker-compose/orion-ld.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ services:
- ORIONLD_MONGO_HOST=mongo-db
- ORIONLD_MULTI_SERVICE=TRUE
- ORIONLD_DISABLE_FILE_LOG=TRUE
command: -dbhost mongo-db -logLevel DEBUG -forwarding -experimental -wip entityMaps
command: -dbhost mongo-db -logLevel DEBUG -forwarding -mongocOnly -wip entityMaps
healthcheck:
test: curl --fail -s http://orion:${ORION_LD_PORT}/version || exit 1
interval: 10s
Expand Down
35 changes: 1 addition & 34 deletions services
Original file line number Diff line number Diff line change
Expand Up @@ -167,43 +167,11 @@ displayServices () {
echo ""
}

addDatabaseIndex () {
printf "Adding appropriate \033[1mMongoDB\033[0m indexes for \033[1;34mOrion\033[0m ..."
docker exec db-mongo mongo --eval '
conn = new Mongo();db.createCollection("orion");
db = conn.getDB("orion");
db.createCollection("entities");
db.entities.createIndex({"_id.servicePath": 1, "_id.id": 1, "_id.type": 1}, {unique: true});
db.entities.createIndex({"_id.type": 1});
db.entities.createIndex({"_id.id": 1});' > /dev/null

docker exec db-mongo mongo --eval '
conn = new Mongo();db.createCollection("orion-openiot");
db = conn.getDB("orion-openiot");
db.createCollection("entities");
db.entities.createIndex({"_id.servicePath": 1, "_id.id": 1, "_id.type": 1}, {unique: true});
db.entities.createIndex({"_id.type": 1});
db.entities.createIndex({"_id.id": 1});' > /dev/null
echo -e " \033[1;32mdone\033[0m"

printf "Adding appropriate \033[1mMongoDB\033[0m indexes for \033[1;36mIoT-Agent\033[0m ..."
docker exec db-mongo mongo --eval '
conn = new Mongo();
db = conn.getDB("iotagentul");
db.getCollectionNames().forEach(c=>db[c].drop());
db.createCollection("devices");
db.devices.createIndex({"_id.service": 1, "_id.id": 1, "_id.type": 1});
db.devices.createIndex({"_id.type": 1});
db.devices.createIndex({"_id.id": 1});
db.createCollection("groups");
db.groups.createIndex({"_id.resource": 1, "_id.apikey": 1, "_id.service": 1});
db.groups.createIndex({"_id.type": 1});' > /dev/null
echo -e " \033[1;32mdone\033[0m"
}

addIoTDatabaseIndex () {
printf "Adding appropriate \033[1mMongoDB\033[0m indexes for \033[1;36mIoT-Agent\033[0m ..."
docker exec db-mongo mongo --eval '
docker exec db-mongo mongosh --eval '
conn = new Mongo();
db = conn.getDB("iotagentul");
db.getCollectionNames().forEach(c=>db[c].drop());
Expand Down Expand Up @@ -238,7 +206,6 @@ case "${command}" in
${dockerCmd} -f docker-compose/common.yml -f docker-compose/orion-ld.yml -p fiware up -d --renew-anon-volumes
displayServices "orion|fiware"
waitForMongo
addDatabaseIndex
waitForOrion
loadData orion:1026
echo -e "\033[1;34m${command}\033[0m is now running and exposed on localhost:${EXPOSED_PORT}"
Expand Down

0 comments on commit 715580f

Please sign in to comment.