-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (27 loc) · 944 Bytes
/
main.py
File metadata and controls
36 lines (27 loc) · 944 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
26
27
28
29
30
31
32
33
34
35
36
import sys
import time
import grpc
from concurrent import futures
from grpc_health.v1.health import HealthServicer
from grpc_health.v1.health_pb2 import HealthCheckResponse
from grpc_health.v1 import health_pb2_grpc
from plugin.python_example import ExamplePlugin
from proto_files import module_pb2_grpc
def main():
server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
module_pb2_grpc.add_ModuleServicer_to_server(ExamplePlugin(), server)
health = HealthServicer()
health.set("plugin", HealthCheckResponse.ServingStatus.Value('SERVING'))
health_pb2_grpc.add_HealthServicer_to_server(health, server)
address = "127.0.0.1:50051"
server.add_insecure_port(address)
server.start()
print(f"1|1|tcp|{address}|grpc")
sys.stdout.flush()
try:
while True:
time.sleep(60)
except KeyboardInterrupt:
server.stop(0)
if __name__ == "__main__":
main()