def serve():
    server = grpc.server(concurrent.futures.ThreadPoolExecutor())
    echo_pb2_grpc.add_EchoServiceServicer_to_server(
        EchoServicer(), server)
    server.add_insecure_port('[::]:50051')
    server.start()
    server.wait_for_termination()
Esempio n. 2
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    echo_pb2_grpc.add_EchoServiceServicer_to_server(EchoService(), server)
    server.add_insecure_port('[::]:9090')
    server.start()
    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        server.stop(0)
Esempio n. 3
0
def serve():
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    echo_pb2_grpc.add_EchoServiceServicer_to_server(EchoServiceServicer(),
                                                    server)
    server.add_insecure_port('[::]:50051')
    server.start()
    logger.debug('### EchoServiceServer -- Starting ...')
    try:
        while True:
            time.sleep(3600)
    except KeyboardInterrupt:
        server.stop(0)
Esempio n. 4
0
def serve():
    service = EchoService()
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=3))

    echo_pb2_grpc.add_EchoServiceServicer_to_server(service, server)
    add_HealthServicer_to_server(service, server)

    logger.info(f"listening on port: {port}")
    server.add_insecure_port(f"[::]:{port}")
    server.start()
    try:
        while True:
            time.sleep(86400)
    except KeyboardInterrupt:
        server.stop(0)
def serve():
    logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s',
                        level=logging.DEBUG)
    port = 50051
    logging.info("Starting server on port %d" % port)
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10), )
    #interceptors=(tracer_interceptor,))
    echo_pb2_grpc.add_EchoServiceServicer_to_server(Echo(), server)

    server.add_insecure_port('[::]:' + str(port))
    server.start()
    prometheus_client.start_http_server(9090)

    try:
        while True:
            time.sleep(_ONE_DAY_IN_SECONDS)
    except KeyboardInterrupt:
        server.stop(0)
def main(args):
    grpc_wsgi_app = grpcWSGI.server.grpcWSGI(None)

    with make_server("", 8080, grpc_wsgi_app) as httpd:
        echo_pb2_grpc.add_EchoServiceServicer_to_server(Echo(), grpc_wsgi_app)
        httpd.serve_forever()
Esempio n. 7
0
    def GetMessage(self, request, context):
        metadata = dict(context.invocation_metadata())
        print(metadata)
        response.message = echo.Response(request.name + request.lastName)
        return echo.Response(response)

    def EchoStream(self, request, context):

        for req in request:
            response = echo.Response(req.name + req.lastName)
            yield echo.NameResponse(response=response)


if __name__ == '__main__':

    port = 50051

    # create a gRPC server
    server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
    rpc.add_EchoServiceServicer_to_server(EchoService(), server)

    print('Starting server. Listening...')
    server.add_insecure_port('[::]:' + str(port))
    server.start()

    # Server starts in background (another thread) so keep waiting
    try:
        while True:
            time.sleep(86400)
    except KeyboardInterrupt:
        server.stop(0)