Exemple #1
0
 def setUp(self):
     self.store = '/tmp/store.json'
     self.dest = '/tmp/dbs'
     self.config = gen_test_config()
     if not os.path.exists(self.dest):
         os.mkdir(self.dest)
     self.handler = DatabaseStore(self.config)
Exemple #2
0
    def setUp(self):
        self.store = '/tmp/store.json'
        self.dest = '/tmp/dbs'
        self.config = gen_test_config()
        if not os.path.exists(self.dest):
            os.mkdir(self.dest)

        self.databases = DatabaseStore(self.config)
        self.default_db_uid = self.databases.index['name_to_uid']['default']
        self._bootstrap_db(self.databases[self.default_db_uid].connector)
        self.handler = Handler(self.databases)
Exemple #3
0
    def setUp(self):
        zmq_context = zmq.Context()
        config = gen_test_config()

        self.database_store = config['database_store']
        self.databases_storage_path = config['databases_storage_path']
        if not os.path.exists(self.databases_storage_path):
            os.mkdir(self.databases_storage_path)
        self.db_handler = DatabaseStore(config)

        # Let's fake a backend for workers to talk to
        self.socket = zmq_context.socket(zmq.DEALER)
        self.socket.bind('inproc://backend')

        self.supervisor = Supervisor(zmq_context, self.db_handler)
Exemple #4
0
def runserver(config):
    setup_loggers(config)
    activity_logger = logging.getLogger("activity_logger")

    databases = DatabaseStore(config)
    backend = Backend(databases, config)
    frontend = Frontend(config)

    poller = zmq.Poller()
    poller.register(backend.socket, zmq.POLLIN)
    poller.register(frontend.socket, zmq.POLLIN)

    activity_logger.info('Elevator server started on %s' % frontend.host)

    while True:
        try:
            sockets = dict(poller.poll())
            if frontend.socket in sockets:
                if sockets[frontend.socket] == zmq.POLLIN:
                    msg = frontend.socket.recv_multipart(copy=False)
                    backend.socket.send_multipart(msg, copy=False)

            if backend.socket in sockets:
                if sockets[backend.socket] == zmq.POLLIN:
                    msg = backend.socket.recv_multipart(copy=False)
                    frontend.socket.send_multipart(msg, copy=False)
        except KeyboardInterrupt:
            activity_logger.info('Gracefully shuthing down workers')
            del backend
            activity_logger.info('Stopping frontend')
            del frontend
            activity_logger.info('Done')
            return
        except Exception as e:
            log_critical(e)
            del backend
            del frontend
            return