def serve_rpc(): plugin = manager.NeutronManager.get_plugin() # If 0 < rpc_workers then start_rpc_listeners would be called in a # subprocess and we cannot simply catch the NotImplementedError. It is # simpler to check this up front by testing whether the plugin supports # multiple RPC workers. if not plugin.rpc_workers_supported(): LOG.debug("Active plugin doesn't implement start_rpc_listeners") if 0 < cfg.CONF.rpc_workers: LOG.error( _LE("'rpc_workers = %d' ignored because " "start_rpc_listeners is not implemented."), cfg.CONF.rpc_workers) raise NotImplementedError() try: rpc = RpcWorker(plugin) if cfg.CONF.rpc_workers < 1: rpc.start() return rpc else: launcher = common_service.ProcessLauncher(wait_interval=1.0) launcher.launch_service(rpc, workers=cfg.CONF.rpc_workers) return launcher except Exception: with excutils.save_and_reraise_exception(): LOG.exception( _LE('Unrecoverable error: please check log for ' 'details.'))
def _launch(self, application, workers=0): service = WorkerService(self, application) if workers < 1: # The API service should run in the current process. self._server = service service.start() systemd.notify_once() else: # The API service runs in a number of child processes. # Minimize the cost of checking for child exit by extending the # wait interval past the default of 0.01s. self._server = common_service.ProcessLauncher(wait_interval=1.0) self._server.launch_service(service, workers=workers)
def start(self, application, file_socket, workers, backlog): self._socket = eventlet.listen(file_socket, family=socket.AF_UNIX, backlog=backlog) if workers < 1: # For the case where only one process is required. self._server = self.pool.spawn_n(self._run, application, self._socket) else: # Minimize the cost of checking for child exit by extending the # wait interval past the default of 0.01s. self._launcher = service.ProcessLauncher(wait_interval=1.0) self._server = WorkerService(self, application) self._launcher.launch_service(self._server, workers=workers)
def _launch(self, application, workers=0): service = WorkerService(self, application) if workers < 1: # The API service should run in the current process. self._server = service service.start() systemd.notify_once() else: # dispose the whole pool before os.fork, otherwise there will # be shared DB connections in child processes which may cause # DB errors. api.dispose() # The API service runs in a number of child processes. # Minimize the cost of checking for child exit by extending the # wait interval past the default of 0.01s. self._server = common_service.ProcessLauncher(wait_interval=1.0) self._server.launch_service(service, workers=workers)
def start(self, application, port, host='0.0.0.0', workers=0): """Run a WSGI server with the given application.""" self._host = host self._port = port backlog = CONF.backlog self._socket = self._get_socket(self._host, self._port, backlog=backlog) if workers < 1: # For the case where only one process is required. self._server = self.pool.spawn(self._run, application, self._socket) else: # Minimize the cost of checking for child exit by extending the # wait interval past the default of 0.01s. self._launcher = common_service.ProcessLauncher(wait_interval=1.0) self._server = WorkerService(self, application) self._launcher.launch_service(self._server, workers=workers)