(self, port, pem_dir)
Server
        :param port: port to listen on.
        :param pem_dir: Directory including certificates
        :return: None
Server
        :param port: port to listen on.
        :param pem_dir: Directory including certificates
        :return: None
Server : param port : port to listen on . : param pem_dir : Directory including certificates : return : None
def Serve(self, port, pem_dir):
        """
        Server
        :param port: port to listen on.
        :param pem_dir: Directory including certificates
        :return: None
        """
        server = grpc.server(futures.ThreadPoolExecutor(max_workers=10),\
        options=[('grpc.max_send_message_length', MAX_MESSAGE_LENGTH),('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH)])
        
        SSE.add_ConnectorServicer_to_server(self, server)

        if pem_dir:
            # Secure connection
            with open(os.path.join(pem_dir, 'sse_server_key.pem'), 'rb') as f:
                private_key = f.read()
            with open(os.path.join(pem_dir, 'sse_server_cert.pem'), 'rb') as f:
                cert_chain = f.read()
            with open(os.path.join(pem_dir, 'root_cert.pem'), 'rb') as f:
                root_cert = f.read()
            credentials = grpc.ssl_server_credentials([(private_key, cert_chain)], root_cert, True)
            server.add_secure_port('[::]:{}'.format(port), credentials)
            logging.info('*** Running server in secure mode on port: {} ***'.format(port))
        else:
            # Insecure connection
            server.add_insecure_port('[::]:{}'.format(port))
            logging.info('*** Running server in insecure mode on port: {} ***'.format(port))

        server.start()
        try:
            while True:
                time.sleep(_ONE_DAY_IN_SECONDS)
        except KeyboardInterrupt:
            server.stop(0)
def Serve ( self , port , pem_dir ) : server = grpc . server ( futures . ThreadPoolExecutor ( max_workers = 10 ) , options = [ ( 'grpc.max_send_message_length' , MAX_MESSAGE_LENGTH ) , ( 'grpc.max_receive_message_length' , MAX_MESSAGE_LENGTH ) ] ) SSE . add_ConnectorServicer_to_server ( self , server ) if pem_dir : # Secure connection with open ( os . path . join ( pem_dir , 'sse_server_key.pem' ) , 'rb' ) as f : private_key = f . read ( ) with open ( os . path . join ( pem_dir , 'sse_server_cert.pem' ) , 'rb' ) as f : cert_chain = f . read ( ) with open ( os . path . join ( pem_dir , 'root_cert.pem' ) , 'rb' ) as f : root_cert = f . read ( ) credentials = grpc . ssl_server_credentials ( [ ( private_key , cert_chain ) ] , root_cert , True ) server . add_secure_port ( '[::]:{}' . format ( port ) , credentials ) logging . info ( '*** Running server in secure mode on port: {} ***' . format ( port ) ) else : # Insecure connection server . add_insecure_port ( '[::]:{}' . format ( port ) ) logging . info ( '*** Running server in insecure mode on port: {} ***' . format ( port ) ) server . start ( ) try : while True : time . sleep ( _ONE_DAY_IN_SECONDS ) except KeyboardInterrupt : server . stop ( 0 )