Example #1
0
def includeme(config):
    Environment.initialize(config.registry.settings, None)
    config.include(add_routes)
    config.add_renderer('taskresponse',
                        'aybu.manager.rest.renderers.TaskResponseRender')
    config.add_renderer(None, 'pyramid.renderers.json_renderer_factory')
    config.scan()
Example #2
0
    def __init__(self, context, config):
        super(AybuManagerDaemonWorker, self).__init__(name='worker')
        self.config = config
        self.log = logging.getLogger(__name__)
        self.context = context
        self.config["sqlalchemy.poolclass"] = NullPool
        self.engine = engine_from_config(self.config, 'sqlalchemy.')
        self.Session = scoped_session(sessionmaker(bind=self.engine))
        Base.metadata.bind = self.engine
        Base.metadata.create_all()
        redis_opts = {k.replace('redis.', ''): self.config[k]
                      for k in self.config
                      if k.startswith('redis.')}
        if 'port' in redis_opts:
            redis_opts['port'] = int(redis_opts['port'])

        self.redis = redis.StrictRedis(**redis_opts)
        self.pub_socket = self.context.socket(zmq.PUB)
        self.pub_socket.bind(self.config['zmq.status_pub_addr'])
        Environment.initialize(self.config, section=None)