openpowerquality / opq

Master repository for all OPQ services
http://openpowerquality.org
18 stars 2 forks source link

MongoDB service startup initialization #235

Open philipmjohnson opened 5 years ago

philipmjohnson commented 5 years ago

Please do work for this task in a branch called issue-235.

(Based upon comments below, I've edited this issue description and title.)

Upon MongoDB service startup via Docker, it would be useful to perform several system startup tasks in an initialization script/file.

To reflect the first-class status of the MongoDB service in OPQ Cloud, please remove the util/mongo directory and create a top-level opq/mongodb directory in which to put these scripts and files. The following should be accomplished by the initialization scripts/files:

philipmjohnson commented 5 years ago

Looks like we already have a "database bootstrap script" which ensures that indexes are created. This might be the place to add collection definitions along with their associated schemas?

anthonyjchriste commented 5 years ago

It's just a JS file that creates the indexes: https://github.com/openpowerquality/opq/blob/master/util/mongod/ensure_indexes.js

I'm not sure if it's a great place to store the schemas or not.

anthonyjchriste commented 5 years ago

There is an associated script as well: https://github.com/openpowerquality/opq/blob/master/util/mongod/ensure_indexes.sh

It's currently not integrated with the mongo docker. Should probably somehow be integrated with the mongo docker to be called every time the mongo docker image starts.

philipmjohnson commented 5 years ago

Interesting. A couple of thoughts:

philipmjohnson commented 5 years ago

Agree that this "Mongo Initialization Script" needs to be integrated into Docker.

philipmjohnson commented 5 years ago

Looks like the measurements collection needs an index on its timestamp_ms field.