-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlaunch_grpc.py
More file actions
25 lines (23 loc) · 897 Bytes
/
launch_grpc.py
File metadata and controls
25 lines (23 loc) · 897 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env python
import argparse
import asyncio
import logging
import os
import sys
if not os.path.exists("proto/rpc_pb2.py"):
import subprocess
subprocess.run(["python", "build_protos.py"], check=True)
from implementations.grpc_impl import GRPCImplementation
async def run_server(port):
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s: %(message)s')
impl = GRPCImplementation(port=port)
await impl.setup()
print("READY", flush=True)
sys.stdout.flush() # Ensure the READY signal is sent immediately
logging.info("Entering idle loop to keep the gRPC server running")
await asyncio.Event().wait()
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("--port", type=int, default=50051, help="Port to bind the gRPC server")
args = parser.parse_args()
asyncio.run(run_server(args.port))