Add emitter and missing mongo-init.sh
continuous-integration/drone Build is passing Details

This commit is contained in:
Léo Carpentier 2022-02-14 11:59:21 +02:00
parent 82b91e7161
commit b90ae0c18d
4 changed files with 18 additions and 8 deletions

View File

@ -66,4 +66,3 @@ services:
network_mode: host
build:
context: ./emitter
entrypoint: /emitter/camtiler.py

View File

@ -1,6 +1,7 @@
FROM python
WORKDIR /emitter
RUN pip install pymongo
COPY ./emitter.py ./
ENTRYPOINT emitter.py
CMD ["python", "./emitter.py"]
LABEL name="emitter"

View File

@ -2,12 +2,11 @@ from pymongo import MongoClient
from bson.objectid import ObjectId
from time import sleep
MONGO_URI="mongodb://127.0.0.1:27017"
MONGO_URI="mongodb://127.0.0.1:27017/default"
client = MongoClient(MONGO_URI)
db = client['default']
col = db['eventlog']
db = MongoClient(MONGO_URI).get_default_database()
while True:
col.insertOne({"foo": "bar"})
db.eventlog.insert_one({ "timestamp": "...", "event": "motion-detected", "started": "...", "finished": "...", "component": "motion-detect", "camera": "Server room", "action": "event",
})
sleep(1)

11
mongo-init.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/bash
mongo <<EOF
rs.initiate({
_id: 'rs0',
members: [
{_id: 0, host: '127.0.0.1:27017'}
]
})
EOF