Skip to content

Commit

Permalink
fix: register service names
Browse files Browse the repository at this point in the history
  • Loading branch information
Neng Wan committed Aug 21, 2023
1 parent 0c08e7d commit 1accfc6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions sea/server/multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from typing import List

import grpc
from grpc_reflection.v1alpha import reflection

from sea import signals

Expand Down Expand Up @@ -45,9 +46,9 @@ def _run_server(self, bind_address):
],
)
self.server = server # set server in slave process
if self.app.config.get("GRPC_REFLECTION", True):
from grpc_reflection.v1alpha import reflection
reflection.enable_server_reflection((reflection.SERVICE_NAME,), server)
# register reflection service
if self.app.config.get("GRPC_REFLECTION_SERVICES"):
reflection.enable_server_reflection((reflection.SERVICE_NAME, *self.app.config["GRPC_REFLECTION_SERVICES"]), self.server)

for _, (add_func, servicer) in self.app.servicers.items():
add_func(servicer(), server)
Expand Down
7 changes: 4 additions & 3 deletions sea/server/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from concurrent import futures

import grpc
from grpc_reflection.v1alpha import reflection

from sea import signals

Expand All @@ -28,9 +29,9 @@ def run(self):
from prometheus_client import start_http_server

start_http_server(self.app.config["PROMETHEUS_PORT"])
if self.app.config.get("GRPC_REFLECTION", True):
from grpc_reflection.v1alpha import reflection
reflection.enable_server_reflection((reflection.SERVICE_NAME,), self.server)
# register reflection service
if self.app.config.get("GRPC_REFLECTION_SERVICES"):
reflection.enable_server_reflection((reflection.SERVICE_NAME, *self.app.config["GRPC_REFLECTION_SERVICES"]), self.server)
# run grpc server
for name, (add_func, servicer) in self.app.servicers.items():
add_func(servicer(), self.server)
Expand Down

0 comments on commit 1accfc6

Please sign in to comment.