[Docs]: Fix Multi-User Port Allocation Conflicts (#3601)
Co-authored-by: zhaochenyang20 <zhaochen20@outlook.com> Co-authored-by: simveit <simp.veitner@gmail.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import weakref
|
||||
|
||||
from sglang.utils import execute_shell_command, reserve_port
|
||||
|
||||
@@ -21,15 +22,29 @@ def patched_post_init(self):
|
||||
|
||||
server_args_mod.ServerArgs.__post_init__ = patched_post_init
|
||||
|
||||
process_socket_map = weakref.WeakKeyDictionary()
|
||||
|
||||
|
||||
def launch_server_cmd(command: str, host: str = "0.0.0.0", port: int = None):
|
||||
"""
|
||||
Launch the server using the given command.
|
||||
If no port is specified, a free port is reserved.
|
||||
"""
|
||||
if port is None:
|
||||
port = reserve_port()
|
||||
port, lock_socket = reserve_port(host)
|
||||
else:
|
||||
lock_socket = None
|
||||
|
||||
extra_flags = (
|
||||
f"--max-running-requests {DEFAULT_MAX_RUNNING_REQUESTS} "
|
||||
f"--max-total-tokens {DEFAULT_MAX_TOTAL_TOKENS} "
|
||||
f"--disable-cuda-graph"
|
||||
)
|
||||
|
||||
full_command = f"{command} --port {port} {extra_flags}"
|
||||
process = execute_shell_command(full_command)
|
||||
|
||||
if lock_socket is not None:
|
||||
process_socket_map[process] = lock_socket
|
||||
|
||||
return process, port
|
||||
|
||||
Reference in New Issue
Block a user