Exemple #1
0
def get_context():
    """
    Create the context to be used for nghttpx, other than the one provided
    by the configs.
    """
    context = {}
    context['backends'] = []
    for service in ServiceRegistry.list_services():
        (ip_address, port) = ServiceRegistry.get_service_address(service)
        backend = {'service': service, 'ip': ip_address, 'port': port}
        context['backends'].append(backend)

    # We get the gateway cert after bootstrapping, but we do want nghttpx
    # to run before that for communication locally. Update the flag for
    # jinja to act upon.
    gateway_cert = get_service_config_value('control_proxy', 'gateway_cert',
                                            None)
    if gateway_cert and os.path.exists(gateway_cert):
        context['use_gateway_cert'] = True
    else:
        context['use_gateway_cert'] = False

    context['dev_mode'] = is_dev_mode()

    context['allow_http_proxy'] = get_service_config_value(
        'control_proxy', 'allow_http_proxy', False)
    context['http_proxy'] = os.getenv('http_proxy', '')
    return context
Exemple #2
0
 def run(self):
     """
     Starts the service and runs the event loop until a term signal
     is received or a StopService rpc call is made on the Service303
     interface.
     """
     logging.info("Starting %s...", self._name)
     (host, port) = ServiceRegistry.get_service_address(self._name)
     self._port = self._server.add_insecure_port('{}:{}'.format(host, port))
     logging.info("Listening on address %s:%d", host, self._port)
     self._state = ServiceInfo.ALIVE
     # Python services are healthy immediately when run
     self._health = ServiceInfo.APP_HEALTHY
     self._server.start()
     self._loop.run_forever()
Exemple #3
0
 async def _get_client(service):
     (ip, port) = ServiceRegistry.get_service_address(service)
     return await aioh2.open_connection(ip, port)