Repository navigation
server: Add support for binding to multiple addresses - #28690
Conversation
b8a4e1e to
0afc4ba
Compare
|
/bot review |
Automated code reviewReview of PR 28690: multiple
|
|
|
||
| Each `--host` value is literal; commas are not separators. A single path ending in `.sock` keeps its existing Unix socket behavior, including commas in the path. Mixing TCP addresses and Unix socket paths is rejected in either order. | ||
|
|
||
| `LLAMA_ARG_HOST` and the preset `host` setting each accept one literal address or path. The first CLI `--host` overrides that value; additional occurrences add addresses. |
There was a problem hiding this comment.
this behavior is inconsistent
ngxson
left a comment
There was a problem hiding this comment.
instead of repeating the --host arg, it's cleaner to allow CSV style input, we already had many other args doing this
example: --host 10.1.2.123,79.52.1.22,::1
and then simply throw error if we are mixing UNIX socket and IP, we should only support one or the other
0afc4ba to
f45e12c
Compare
|
Amended. |
| string_format("IP addresses to listen on, comma-separated, or UNIX socket paths ending in .sock (default: %s)", string_join(params.hostnames, ",").c_str()), | ||
| [](common_params & params, const std::string & value) { | ||
| params.hostname = value; | ||
| params.hostnames = string_split(value, ","); |
| add_opt(common_arg( | ||
| {"--host"}, "HOST", | ||
| string_format("ip address to listen, or bind to an UNIX socket if the address ends with .sock (default: %s)", params.hostname.c_str()), | ||
| string_format("IP addresses to listen on, comma-separated, or UNIX socket paths ending in .sock (default: %s)", string_join(params.hostnames, ",").c_str()), |
There was a problem hiding this comment.
| string_format("IP addresses to listen on, comma-separated, or UNIX socket paths ending in .sock (default: %s)", string_join(params.hostnames, ",").c_str()), | |
| string_format("IP addresses to listen on, comma-separated, or UNIX socket paths ending in .sock (default: %s)", params.hostnames[0].c_str()), |
There was a problem hiding this comment.
some test cases seem redundant
just one test case is generally enough for a simple feature like this
| ## Listening on multiple addresses | ||
|
|
||
| Use `--host 127.0.0.1,::1` to listen on several addresses. Each address serves the same routes, including streaming responses. All addresses must bind successfully; otherwise startup fails and closes the sockets already bound. | ||
|
|
||
| All addresses use `--port`. With `--port 0`, the first address selects an available port and the remaining addresses must bind that same port. The startup log lists every listening URL. HTTP workers share the existing `--threads-http` budget, with one accept thread per address. | ||
|
|
||
| Unix socket paths ending in `.sock` keep their existing behavior. TCP addresses and Unix socket paths cannot be mixed. | ||
|
|
||
| `LLAMA_ARG_HOST` and the preset `host` setting accept the same comma-separated format. |
There was a problem hiding this comment.
this whole section seems redundant, better to remove this
| if (!listening_address.empty()) { | ||
| listening_address += ", "; | ||
| } | ||
| listening_address += is_sock ? string_format("unix://%s", host.c_str()) | ||
| : string_format("%s://%s:%d", is_ssl ? "https" : "http", common_http_format_host(host).c_str(), port); |
There was a problem hiding this comment.
looks quite overkill, let's just do it simple:
for (addr : addresses) {
LOG_INF("Listening on: %s", addr.c_str())
}
| const bool use_unix_sockets = string_ends_with(pimpl->hosts.front(), ".sock"); | ||
| for (const auto & host : pimpl->hosts) { | ||
| if (host.empty() || string_ends_with(host, ".sock") != use_unix_sockets) { | ||
| SRV_ERR("%s", "--host requires non-empty TCP addresses or Unix socket paths; TCP and Unix socket addresses cannot be mixed\n"); |
There was a problem hiding this comment.
since we have different thread pool for each addr, maybe mixing TCP + UNIX is trivial after all?
There was a problem hiding this comment.
mixed TCP/Unix sockets needed no new infrastructure, and testing passed in both address orders
Assisted-by: Codex
f45e12c to
5a1ffdb
Compare
|
Amended. |
…8690) Squash of ggml-org#28690 at f99f961. --host takes a comma-separated list of addresses / unix socket paths. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
sorry for the delay, there are still some minor issues that need to be addressed before merging, I will push them today or tmr |
* Add support for binding llama-server to multiple addresses Assisted-by: Codex * remove redundant thread handler * make it clear about overlapping addr * reject --port 0 with multiple tcp addr * improve arg handler * nits * fix test * nits 2 * nits * nits 2 --------- Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
* Add support for binding llama-server to multiple addresses Assisted-by: Codex * remove redundant thread handler * make it clear about overlapping addr * reject --port 0 with multiple tcp addr * improve arg handler * nits * fix test * nits 2 * nits * nits 2 --------- Co-authored-by: Xuan Son Nguyen <son@huggingface.co>
Binding
llama-serverto a VPN address currently makes it unavailable through localhost, breaking clients that default to localhost. Supporting multiple addresses lets one server remain accessible through both.--hostnow accepts a comma-separated list of IP addresses and Unix socket paths. The server creates one listener per address, all serving the same API and model through a shared HTTP worker pool.TCP listeners share the configured port. With
--port 0, the first TCP listener selects an available port for the others. Every address must bind successfully; otherwise, startup fails and closes the listeners already bound. Each listening URL is logged separately.