Пример #1
0
def main():
    amqp_url = config.get('DEFAULT', 'amqp_url')
    exchange = config.get('DEFAULT', 'exchange')
    routing_key = config.get('DEFAULT', 'routing_key')

    consumer = Consumer(amqp_url, exchange, routing_key)
    try:
        consumer.run()
    except KeyboardInterrupt:
        consumer.exit()
Пример #2
0
# Centrally handle the statsd object

import statsd
from chronostack.config import config


host = config.get('statsd', 'host')
port = config.get('statsd', 'port')
region = config.get('statsd', 'region')
statsd_conn = statsd.StatsClient(host, port, prefix=region)
Пример #3
0
# Centrally handle the redis object

import redis
from chronostack.config import config

redis_host = config.get('redis', 'host')
redis_port = config.get('redis', 'port')
redis_db = config.get('redis', 'db')

redis_conn = redis.StrictRedis(host=redis_host, port=redis_port, db=redis_db)
Пример #4
0
# Centrally handle the logger

import logging
from chronostack.config import config


config_log_level = config.get('logging', 'level')
if config_log_level == 'DEBUG':
    log_level = logging.DEBUG
if config_log_level == 'INFO':
    log_level = logging.INFO
if config_log_level == 'WARNING':
    log_level = logging.WARNING
if config_log_level == 'ERROR':
    log_level = logging.ERROR
if config_log_level == 'CRITICAL':
    log_level = logging.CRITICAL

logger = logging.getLogger(__name__)
logger.setLevel(log_level)

formatter = logging.Formatter('%(asctime)s %(levelname)s - %(message)s')

stdout = config.get('logging', 'stdout')

ch = logging.StreamHandler()
ch.setLevel(log_level)
ch.setFormatter(formatter)
logger.addHandler(ch)

log_file = config.get('logging', 'log_file')