Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion vllm/entrypoints/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async def run_server(args: Namespace,
if __name__ == "__main__":
parser = FlexibleArgumentParser()
parser.add_argument("--host", type=str, default=None)
parser.add_argument("--port", type=int, default=8000, ge=1024, le=65535)
parser.add_argument("--port", type=parser.check_port, default=8000)
parser.add_argument("--ssl-keyfile", type=str, default=None)
parser.add_argument("--ssl-certfile", type=str, default=None)
parser.add_argument("--ssl-ca-certs",
Expand Down
11 changes: 11 additions & 0 deletions vllm/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,17 @@ def parse_args(self, args=None, namespace=None):

return super().parse_args(processed_args, namespace)

def check_port(self, value):
try:
value = int(value)
except ValueError:
raise argparse.ArgumentTypeError("Port must be an integer")

if not (1024 <= value <= 65535):
raise argparse.ArgumentTypeError("Port must be between 1024 and 65535")

return value

def _pull_args_from_config(self, args: List[str]) -> List[str]:
"""Method to pull arguments specified in the config file
into the command-line args variable.
Expand Down