def main(skip_rabbit=False): # pragma: no cover # setup rabbit and monitoring of the network pmain = Monitor(skip_rabbit=skip_rabbit) if not skip_rabbit: rabbit = Rabbit() host = pmain.controller['FA_RABBIT_HOST'] port = int(pmain.controller['FA_RABBIT_PORT']) exchange = 'topic-poseidon-internal' queue_name = 'poseidon_main' binding_key = ['poseidon.algos.#', 'poseidon.action.#'] retval = rabbit.make_rabbit_connection(host, port, exchange, queue_name, binding_key) pmain.rabbit_channel_local = retval[0] pmain.rabbit_channel_connection_local = retval[1] pmain.rabbit_thread = rabbit.start_channel(pmain.rabbit_channel_local, rabbit_callback, queue_name, pmain.m_queue) rabbit = Rabbit() host = pmain.controller['FA_RABBIT_HOST'] port = pmain.controller['FA_RABBIT_PORT'] exchange = pmain.controller['FA_RABBIT_EXCHANGE'] queue_name = 'poseidon_main' binding_key = [pmain.controller['FA_RABBIT_ROUTING_KEY'] + '.#'] retval = rabbit.make_rabbit_connection(host, port, exchange, queue_name, binding_key) pmain.rabbit_channel_local = retval[0] pmain.rabbit_channel_connection_local_fa = retval[1] pmain.rabbit_thread = rabbit.start_channel(pmain.rabbit_channel_local, rabbit_callback, queue_name, pmain.m_queue) pmain.schedule_thread.start() # loop here until told not to try: pmain.process() except Exception as e: logger.error('process() exception: {0}'.format(str(e))) pmain.shutdown()
def main(): # pragma: no cover logging.getLogger('pika').setLevel(logging.WARNING) Logger() logger = logging.getLogger('main') pmain = Monitor(logger, CTRL_C) host = pmain.controller['FA_RABBIT_HOST'] port = int(pmain.controller['FA_RABBIT_PORT']) rabbit = Rabbit() exchange = 'topic-poseidon-internal' binding_key = ['poseidon.algos.#', 'poseidon.action.#'] rabbit.make_rabbit_connection(host, port, exchange, binding_key) rabbit.start_channel(pmain.rabbit_callback, pmain.m_queue) pmain.rabbits.append(rabbit) rabbit = Rabbit() exchange = pmain.controller['FA_RABBIT_EXCHANGE'] binding_key = [pmain.controller['FA_RABBIT_ROUTING_KEY'] + '.#'] rabbit.make_rabbit_connection(host, port, exchange, binding_key) rabbit.start_channel(pmain.rabbit_callback, pmain.m_queue) pmain.rabbits.append(rabbit) pmain.schedule_thread.start() # loop here until told not to try: pmain.process() except Exception as e: logger.error('process() exception: {0}'.format(str(e))) pmain.shutdown()