mirror of
https://github.com/JHUAPL/SIMoN.git
synced 2026-01-09 14:57:56 -05:00
issue #6 unique mongo instance for simon to avoid conflict with other instances
Former-commit-id: ce2690dd13f6b31dc2a9cc83ec6c188f14a25b47
This commit is contained in:
@@ -56,7 +56,7 @@ Additionally, install `make`, so that the shell commands that operate SIMoN can
|
||||
* `make clean` to stop all models and clear the database
|
||||
|
||||
## Visualization
|
||||
SIMoN stores all of the data outputs from the models as documents in a Mongo database (container name `mongodb`, accessible via the default Mongo port 27017).
|
||||
SIMoN stores all of the data outputs from the models as documents in a Mongo database (the `simon_mongodb` container).
|
||||
|
||||
You can retrieve a document and save it as a JSON file using the `export.sh` bash script in the `viz` directory.
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
{
|
||||
"mongo_port": 27017,
|
||||
|
||||
"boot_timer": 60,
|
||||
"watchdog_timer": 60,
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ class Broker:
|
||||
self.watchdog_timer = config['watchdog_timer'] # units: seconds
|
||||
self.max_incstep = config['max_incstep'] # the number of increments to run before shutting down
|
||||
self.initial_year = config['initial_year'] # the year that corresponds to incstep 0 (the data in the config directory)
|
||||
self.mongo_port = config['mongo_port'] # the port for the SIMoN Mongo instance (needs to be the same port as in the build/docker-compose.yml file)
|
||||
|
||||
self.status = 'booting'
|
||||
self.pub_queue = Queue()
|
||||
@@ -45,7 +46,7 @@ class Broker:
|
||||
"""
|
||||
|
||||
try:
|
||||
self.client = pymongo.MongoClient('mongodb://mongodb:27017/')
|
||||
self.client = pymongo.MongoClient(f'mongodb://simon_mongodb:{self.mongo_port}/')
|
||||
logging.info("connected to Mongo DB")
|
||||
except Exception as e:
|
||||
logging.error("failed to connect to Mongo DB")
|
||||
|
||||
@@ -27,9 +27,9 @@ services:
|
||||
volumes:
|
||||
- ../models/examples/power_demand:/opt:ro
|
||||
|
||||
mongodb:
|
||||
simon_mongodb:
|
||||
image: mongo:latest
|
||||
container_name: mongodb
|
||||
container_name: simon_mongodb
|
||||
labels:
|
||||
simon: "database"
|
||||
expose:
|
||||
@@ -37,7 +37,7 @@ services:
|
||||
ports:
|
||||
- "27017:27017"
|
||||
environment:
|
||||
- MONGO_URI=mongodb:27017
|
||||
- MONGO_URI=simon_mongodb:27017
|
||||
|
||||
broker:
|
||||
build: ../broker/
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
|
||||
MODEL_NAME=$1
|
||||
YEAR=$2
|
||||
DB_CONTAINER=${3:-"mongodb"}
|
||||
DB_CONTAINER=${3:-"simon_mongodb"}
|
||||
|
||||
JSON_DATA="/"$YEAR"_"$MODEL_NAME".json"
|
||||
|
||||
docker start "simon_mongodb"
|
||||
|
||||
# retrieve the document from the database and save it as a JSON file
|
||||
docker exec -it $DB_CONTAINER \
|
||||
mongoexport --db broker --collection sub --limit 1 \
|
||||
|
||||
Reference in New Issue
Block a user