[router][grpc] Add serve_grpc to launch_server and log id for HealthCheck (#11564)

This commit is contained in:
Chang Su
2025-10-13 16:07:19 -07:00
committed by GitHub
parent 065ce81574
commit 887c2b4575
9 changed files with 68 additions and 93 deletions
+5 -25
View File
@@ -22,8 +22,8 @@ from grpc_reflection.v1alpha import reflection
import sglang
from sglang.srt.disaggregation.utils import FAKE_BOOTSTRAP_HOST, DisaggregationMode
from sglang.srt.entrypoints.grpc_request_manager import GrpcRequestManager
from sglang.srt.grpc import sglang_scheduler_pb2, sglang_scheduler_pb2_grpc
from sglang.srt.grpc.grpc_request_manager import GrpcRequestManager
from sglang.srt.managers.data_parallel_controller import (
run_data_parallel_controller_process,
)
@@ -68,6 +68,8 @@ def _launch_scheduler_process_only(
# Configure global environment
configure_logger(server_args)
server_args.check_server_args()
# Fix CUDA multiprocessing issues - must be called before any CUDA operations
mp.set_start_method("spawn", force=True)
# Allocate ports for inter-process communications
if port_args is None:
@@ -317,7 +319,8 @@ class SGLangSchedulerServicer(sglang_scheduler_pb2_grpc.SglangSchedulerServicer)
Check the health of the inference server by sending a special request to generate one token.
Similar to HTTP server's /health endpoint.
"""
logger.info("Receive health check request")
rid = f"HEALTH_CHECK_{time.time()}"
logger.info(f"Receive health check request: {rid}")
if self.request_manager.gracefully_exit:
logger.info(
@@ -328,7 +331,6 @@ class SGLangSchedulerServicer(sglang_scheduler_pb2_grpc.SglangSchedulerServicer)
)
# Create a special health check request
rid = f"HEALTH_CHECK_{time.time()}"
sampling_params = SGLSamplingParams(max_new_tokens=1, temperature=0.0)
sampling_params.normalize(tokenizer=None)
@@ -919,25 +921,3 @@ async def serve_grpc(
proc.join(timeout=1.0)
logger.info("All scheduler processes terminated")
def main():
"""Main entry point for standalone gRPC server."""
# Fix CUDA multiprocessing issues - must be called before any CUDA operations
mp.set_start_method("spawn", force=True)
parser = argparse.ArgumentParser(description="SGLang Standalone gRPC Server")
ServerArgs.add_cli_args(parser)
args = parser.parse_args()
server_args = ServerArgs.from_cli_args(args)
# Run server
asyncio.run(
serve_grpc(
server_args=server_args,
)
)
if __name__ == "__main__":
main()