def start_pyrox(other_cfg=None): config = load_config(other_cfg) if other_cfg else load_config() # Init logging logging_manager = get_log_manager() logging_manager.configure(config) # Create a PluginManager plugin_manager = pynsive.PluginManager() for path in config.core.plugin_paths: plugin_manager.plug_into(path) # Resolve our filter chains try: filter_pipeline_factories = _build_fc_factories(config) except Exception as ex: _LOG.exception(ex) return -1 # Create proxy server ref http_proxy = TornadoHttpProxy( filter_pipeline_factories, config.routing.upstream_hosts[0]) _LOG.info('Upstream targets are: {}'.format( ['http://{0}:{1}'.format(dst[0], dst[1]) for dst in config.routing.upstream_hosts])) # Set bind host bind_host = config.core.bind_host.split(':') if len(bind_host) != 2: raise ConfigurationError('bind_host must have a port specified') # Bind the server http_proxy.bind(address=bind_host[0], port=int(bind_host[1])) _LOG.info('Pyrox listening on: http://{0}:{1}'.format( bind_host[0], bind_host[1])) # Start Tornado http_proxy.start(config.core.processes) IOLoop.instance().start()