def start_proxy(sockets, config): # Take over SIGTERM and SIGINT signal.signal(signal.SIGTERM, stop_child) signal.signal(signal.SIGINT, stop_child) # Create a PluginManager plugin_manager = pynsive.PluginManager() for path in config.core.plugin_paths: plugin_manager.plug_into(path) # Resolve our filter chains try: if config.pipeline.use_singletons: filter_pipeline_factories = _build_singleton_plfactories(config) else: filter_pipeline_factories = _build_plfactories(config) except Exception as ex: _LOG.exception(ex) return -1 # Load any SSL configurations ssl_options = None cert_file = config.ssl.cert_file key_file = config.ssl.key_file if None not in (cert_file, key_file): ssl_options = dict() ssl_options['certfile'] = cert_file ssl_options['keyfile'] = key_file _LOG.debug('SSL enabled: {}'.format(ssl_options)) # Create proxy server ref http_proxy = TornadoHttpProxy(filter_pipeline_factories, config.routing.upstream_hosts, ssl_options) # Add our sockets for watching http_proxy.add_sockets(sockets) # Start tornado IOLoop.current().start()