def main(): args = get_args() logger = get_logger("article_service", args.v) db_channel = get_service_channel(logger, "DB_SERVICE_HOST", 1798) db_stub = database_pb2_grpc.DatabaseStub(db_channel) create_channel = get_service_channel(logger, "CREATE_SERVICE_HOST", 1922) create_stub = create_pb2_grpc.CreateStub(create_channel) search_channel = get_service_channel(logger, "SEARCH_SERVICE_HOST", 1886) search_stub = search_pb2_grpc.SearchStub(search_channel) logger.info("Creating article server") mdc_channel = get_service_channel(logger, "MDC_SERVICE_HOST", 1937) mdc_stub = mdc_pb2_grpc.ConverterStub(mdc_channel) server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) users_util = UsersUtil(logger, db_stub) recommender_util = RecommendersUtil(logger, db_stub) post_recommendation_stub = recommender_util.get_post_recommendation_stub() article_pb2_grpc.add_ArticleServicer_to_server( ArticleServicer(create_stub, db_stub, mdc_stub, search_stub, logger, users_util, post_recommendation_stub), server) server.add_insecure_port('0.0.0.0:1601') logger.info("Starting article server on port 1601") server.start() try: while True: time.sleep(60 * 60 * 24) # One day except KeyboardInterrupt: db_channel.close() create_channel.close() pass
def main(): logger = get_logger("likes_service") db_stub = get_db_stub(logger) user_util = UsersUtil(logger, db_stub) activ_util = ActivitiesUtil(logger, db_stub) recommender_util = RecommendersUtil(logger, db_stub) post_recommendation_stub = recommender_util.get_post_recommendation_stub() server = grpc.server(futures.ThreadPoolExecutor(max_workers=10)) like_pb2_grpc.add_S2SLikeServicer_to_server( S2SLikeServicer(logger, db_stub, user_util, activ_util, post_recommendation_stub), server) server.add_insecure_port("0.0.0.0:1848") logger.info("Starting Like service on port 1848") server.start() try: while True: time.sleep(60 * 60 * 24) # One day except KeyboardInterrupt: pass