def server_context(service, **kwargs): server_transport = ZeroRPCServerTransport.create_tcp(8192) server = Server(transport=server_transport, service=service, **kwargs) server.bind() try: yield server finally: if server: server.unbind()
def rpc_server(config, signal_upstart, apply_mock_patches): from infi.rpc import Server, ZeroRPCServerTransport from infi.app_repo.service import AppRepoService from infi.app_repo.mock import patch_all, empty_context from infi.app_repo.utils import pretty_print, jsonify_arguments with (patch_all if apply_mock_patches else empty_context)(): transport = ZeroRPCServerTransport.create_tcp(config.rpcserver.port, config.rpcserver.address) service = AppRepoService(config) logger.debug("binding RPC server") server = Server(transport, service) server.bind() if signal_upstart: from infi.app_repo.upstart import signal_init_that_i_am_ready signal_init_that_i_am_ready() server._shutdown_event.wait() server.unbind()
def rpc_server_context(self, config): from infi.rpc import Server, ZeroRPCServerTransport from infi.app_repo.service import AppRepoService transport = ZeroRPCServerTransport.create_tcp(config.rpcserver.port, config.rpcserver.address) service = AppRepoService(config) server = Server(transport, service) server.bind() try: with self.patch_is_really_functions(): yield server finally: server.request_shutdown() server._shutdown_event.wait() server.unbind()
def rpc_server(config, apply_mock_patches): from infi.rpc import Server, ZeroRPCServerTransport from infi.app_repo.service import AppRepoService from infi.app_repo.mock import patch_all, empty_context from infi.app_repo.utils import pretty_print, jsonify_arguments with (patch_all if apply_mock_patches else empty_context)(): transport = ZeroRPCServerTransport.create_tcp(config.rpcserver.port, config.rpcserver.address) service = AppRepoService(config) logger.debug("binding RPC server") server = Server(transport, service) server.bind() server._shutdown_event.wait() server.unbind()