Skip to content

Commit

Permalink
feat: enable grpc reflection
Browse files Browse the repository at this point in the history
  • Loading branch information
Neng Wan committed Aug 21, 2023
1 parent 6c60a91 commit 0c08e7d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
grpcio>=1.27.0,<1.49.0
grpcio-tools>=1.27.0,<1.49.0
grpcio-reflection
protobuf<4.0.0
pendulum
blinker
Expand Down
3 changes: 3 additions & 0 deletions sea/server/multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,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)

for _, (add_func, servicer) in self.app.servicers.items():
add_func(servicer(), server)
Expand Down
3 changes: 3 additions & 0 deletions sea/server/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,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)
# run grpc server
for name, (add_func, servicer) in self.app.servicers.items():
add_func(servicer(), self.server)
Expand Down

0 comments on commit 0c08e7d

Please sign in to comment.