From 83db40104c05e4f3466cfd48a3da3ede627f47ec Mon Sep 17 00:00:00 2001 From: Olivier MEDOC Date: Tue, 10 Jan 2017 18:18:55 +0100 Subject: [PATCH] import pystemon-feeder configuration from the central configuration file --- bin/feeder/pystemon-feeder.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/feeder/pystemon-feeder.py b/bin/feeder/pystemon-feeder.py index 1a9088b3..d36ed66f 100755 --- a/bin/feeder/pystemon-feeder.py +++ b/bin/feeder/pystemon-feeder.py @@ -24,13 +24,24 @@ import sys import time import redis import base64 +import os +import ConfigParser -port = "5556" -pystemonpath = "/home/pystemon/pystemon/" +configfile = os.path.join(os.environ['AIL_BIN'], 'packages/config.cfg') +if not os.path.exists(configfile): + raise Exception('Unable to find the configuration file. \ + Did you set environment variables? \ + Or activate the virtualenv.') + +cfg = ConfigParser.ConfigParser() +cfg.read(configfile) + +zmq_url = cfg.get("ZMQ_Global", "address") +pystemonpath = cfg.get("Directories", "pystemonpath") context = zmq.Context() socket = context.socket(zmq.PUB) -socket.bind("tcp://*:%s" % port) +socket.bind(zmq_url) # check https://github.com/cvandeplas/pystemon/blob/master/pystemon.yaml#L16 r = redis.StrictRedis(host='localhost', db=10)