Ejemplo n.º 1
0
  def app_main(self, config, options, args):
    logging.info("Beginning...")

    # read the db url from the config
    db_url = db.create_url_from_config(config['db'])
    # get the broker and queue config
    broker_url = message_queue.create_url_from_config(config['amqp']['broker'])
    # get exchange information
    self.amqp_exchange = config['amqp']['exchange']['name']

    # initialize the db engine & session
    db.configure_session(db_url)
    data_access.service.initialize()
    data_access.post_type.initialize()

    # get message broker client and store in instance -- used for both receiving and sending
    self.client = message_queue.create_message_client(broker_url)

    self.handlers = {}
    for service in _services_configuration(config):
      self.handlers[service['name']] = event_updater.from_service_name(
          service['name'],
          service['oauth'])

    logging.info('Queue broker URL: %s', broker_url)
    logging.debug('Active handlers: %s', self.handlers)

    message_queue.create_queues_from_config(self.client, config['amqp'])
    message_queue.join(
        self.client,
        config['amqp']['queues']['updater']['queue'],
        self.handler)

    logging.info("Finished...")
Ejemplo n.º 2
0
  def app_main(self, config, options, args):
    logging.info("Beginning...")

    # read the db url from the config
    db_url = db.create_url_from_config(config['db'])
    # get the broker and queue config
    broker_url = message_queue.create_url_from_config(config['amqp']['broker'])
    # get the maximum priority
    max_priority = int(config['scanner']['maximum_priority'])
    min_duration = float(config['scanner']['iteration_minimum_duration'])
    min_duration = datetime.timedelta(seconds=min_duration)

    # initialize the db engine & session
    db.configure_session(db_url)
    service.initialize()
    post_type.initialize()

    # Create event processor
    self.processor = event_processor.EventProcessor(
        max_priority,
        min_duration,
        config['oauth'])

    logging.info('Queue broker URL: %s', broker_url)

    # get message broker client and store in instance -- used for both receiving and sending
    self.client = message_queue.create_message_client(broker_url)
    message_queue.create_queues_from_config(self.client, config['amqp'])

    message_queue.join(
        self.client,
        config['amqp']['queues']['processor']['queue'],
        self.handler)

    logging.info("Finished...")