-
Notifications
You must be signed in to change notification settings - Fork 0
/
stationd.py
31 lines (26 loc) · 1018 Bytes
/
stationd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# ECN Station Daemon
# Processes telemetry data for all stations: ECN Stationary v1, ECN Stationary v2, ECN Mobile v2
import logging
import os
from pymongo import MongoClient
from dotenv import load_dotenv
from ecn.amqp import AmqpProcessor
from ecn.mobile import MobileHandler
from ecn.stationary_v1 import StationaryV1Handler
load_dotenv(verbose=True)
MONGODB_URI = os.environ['MONGODB_URI']
AMQP_HOST = os.environ['AMQP_HOST']
AMQP_VHOST = os.environ['AMQP_VHOST']
AMQP_USER = os.environ['AMQP_USER']
AMQP_PASSWORD = os.environ['AMQP_PASSWORD']
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.info('Connecting to MongoDB...')
mongo = MongoClient(MONGODB_URI)
db = mongo.ecn
processor = AmqpProcessor()
processor.stationary_v1_handler = StationaryV1Handler(db)
processor.mobile_handler = MobileHandler(db)
#processor.connect(AMQP_HOST, AMQP_VHOST, AMQP_USER, AMQP_PASSWORD)
#processor.run()
processor.connect_and_run_forever(AMQP_HOST, AMQP_VHOST, AMQP_USER, AMQP_PASSWORD)