mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-21 15:49:31 +08:00
[Feature] support controller port in multi api server (#3898)
Some checks failed
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Deploy GitHub Pages / deploy (push) Has been cancelled
Publish Job / publish_pre_check (push) Has been cancelled
Publish Job / print_publish_pre_check_outputs (push) Has been cancelled
Publish Job / FD-Clone-Linux (push) Has been cancelled
Publish Job / Show Code Archive Output (push) Has been cancelled
Publish Job / BUILD_SM8090 (push) Has been cancelled
Publish Job / BUILD_SM8689 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8090 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8689 (push) Has been cancelled
Publish Job / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
Publish Job / Run FastDeploy LogProb Tests (push) Has been cancelled
Publish Job / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
Publish Job / Run Base Tests (push) Has been cancelled
Publish Job / Run Accuracy Tests (push) Has been cancelled
Publish Job / Run Stable Tests (push) Has been cancelled
CI Images Build / FD-Clone-Linux (push) Has been cancelled
CI Images Build / Show Code Archive Output (push) Has been cancelled
CI Images Build / CI Images Build (push) Has been cancelled
CI Images Build / BUILD_SM8090 (push) Has been cancelled
CI Images Build / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
CI Images Build / Run FastDeploy LogProb Tests (push) Has been cancelled
CI Images Build / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
CI Images Build / Run Base Tests (push) Has been cancelled
CI Images Build / Run Accuracy Tests (push) Has been cancelled
CI Images Build / Run Stable Tests (push) Has been cancelled
CI Images Build / Publish Docker Images Pre Check (push) Has been cancelled
Some checks failed
CE Compile Job / ce_job_pre_check (push) Has been cancelled
CE Compile Job / print_ce_job_pre_check_outputs (push) Has been cancelled
CE Compile Job / FD-Clone-Linux (push) Has been cancelled
CE Compile Job / Show Code Archive Output (push) Has been cancelled
CE Compile Job / BUILD_SM8090 (push) Has been cancelled
CE Compile Job / BUILD_SM8689 (push) Has been cancelled
CE Compile Job / CE_UPLOAD (push) Has been cancelled
Deploy GitHub Pages / deploy (push) Has been cancelled
Publish Job / publish_pre_check (push) Has been cancelled
Publish Job / print_publish_pre_check_outputs (push) Has been cancelled
Publish Job / FD-Clone-Linux (push) Has been cancelled
Publish Job / Show Code Archive Output (push) Has been cancelled
Publish Job / BUILD_SM8090 (push) Has been cancelled
Publish Job / BUILD_SM8689 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8090 (push) Has been cancelled
Publish Job / PADDLE_PYPI_UPLOAD_8689 (push) Has been cancelled
Publish Job / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
Publish Job / Run FastDeploy LogProb Tests (push) Has been cancelled
Publish Job / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
Publish Job / Run Base Tests (push) Has been cancelled
Publish Job / Run Accuracy Tests (push) Has been cancelled
Publish Job / Run Stable Tests (push) Has been cancelled
CI Images Build / FD-Clone-Linux (push) Has been cancelled
CI Images Build / Show Code Archive Output (push) Has been cancelled
CI Images Build / CI Images Build (push) Has been cancelled
CI Images Build / BUILD_SM8090 (push) Has been cancelled
CI Images Build / Run FastDeploy Unit Tests and Coverage (push) Has been cancelled
CI Images Build / Run FastDeploy LogProb Tests (push) Has been cancelled
CI Images Build / Extracted partial CE model tasks to run in CI. (push) Has been cancelled
CI Images Build / Run Base Tests (push) Has been cancelled
CI Images Build / Run Accuracy Tests (push) Has been cancelled
CI Images Build / Run Stable Tests (push) Has been cancelled
CI Images Build / Publish Docker Images Pre Check (push) Has been cancelled
* Update serving_chat.py * Update serving_completion.py * Update serving_completion.py * Update multi_api_server.py
This commit is contained in:
@@ -25,20 +25,30 @@ from fastdeploy.utils import get_logger, is_port_available
|
||||
logger = get_logger("multi_api_server", "multi_api_server.log")
|
||||
|
||||
|
||||
def start_servers(server_count, server_args, ports, metrics_ports):
|
||||
def start_servers(server_count, server_args, ports, metrics_ports, controller_ports):
|
||||
processes = []
|
||||
logger.info(f"Starting servers on ports: {ports} with args: {server_args} and metrics ports: {metrics_ports}")
|
||||
for i in range(len(server_args)):
|
||||
if server_args[i] == "--engine-worker-queue-port":
|
||||
engine_worker_queue_port = server_args[i + 1].split(",")
|
||||
break
|
||||
check_param(ports, server_count)
|
||||
check_param(metrics_ports, server_count)
|
||||
check_param(engine_worker_queue_port, server_count)
|
||||
if not check_param(ports, server_count):
|
||||
return
|
||||
if not check_param(metrics_ports, server_count):
|
||||
return
|
||||
if not check_param(engine_worker_queue_port, server_count):
|
||||
return
|
||||
if controller_ports != "-1":
|
||||
controller_ports = controller_ports.split(",")
|
||||
if not check_param(controller_ports, server_count):
|
||||
return
|
||||
else:
|
||||
controller_ports = [-1] * server_count
|
||||
# check_param(server_args, server_count)
|
||||
for i in range(server_count):
|
||||
port = int(ports[i])
|
||||
metrics_port = int(metrics_ports[i])
|
||||
controller_port = int(controller_ports[i])
|
||||
|
||||
env = os.environ.copy()
|
||||
env["FD_LOG_DIR"] = f"log_{i}"
|
||||
@@ -51,6 +61,8 @@ def start_servers(server_count, server_args, ports, metrics_ports):
|
||||
str(port),
|
||||
"--metrics-port",
|
||||
str(metrics_port),
|
||||
"--controller-port",
|
||||
str(controller_port),
|
||||
"--local-data-parallel-id",
|
||||
str(i),
|
||||
]
|
||||
@@ -69,7 +81,8 @@ def check_param(ports, num_servers):
|
||||
for port in ports:
|
||||
logger.info(f"check port {port}")
|
||||
if not is_port_available("0.0.0.0", int(port)):
|
||||
raise ValueError(f"Port {port} is already in use.")
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
@@ -77,6 +90,7 @@ def main():
|
||||
parser.add_argument("--ports", default="8000,8002", type=str, help="ports to the http server")
|
||||
parser.add_argument("--num-servers", default=2, type=int, help="number of workers")
|
||||
parser.add_argument("--metrics-ports", default="8800,8802", type=str, help="ports for metrics server")
|
||||
parser.add_argument("--controller-ports", default="-1", type=str, help="ports for controller server port")
|
||||
parser.add_argument("--args", nargs=argparse.REMAINDER, help="remaining arguments are passed to api_server.py")
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -90,6 +104,7 @@ def main():
|
||||
server_args=args.args,
|
||||
ports=args.ports.split(","),
|
||||
metrics_ports=args.metrics_ports.split(","),
|
||||
controller_ports=args.controller_ports,
|
||||
)
|
||||
|
||||
try:
|
||||
|
Reference in New Issue
Block a user