mirror of
https://github.com/ggerganov/llama.cpp.git
synced 2024-12-27 03:44:35 +00:00
server : bind to any port when specified (#10590)
This commit is contained in:
parent
6acce39710
commit
86dc11c5bc
@ -3347,8 +3347,18 @@ int main(int argc, char ** argv) {
|
|||||||
llama_backend_free();
|
llama_backend_free();
|
||||||
};
|
};
|
||||||
|
|
||||||
// bind HTTP listen port, run the HTTP server in a thread
|
// bind HTTP listen port
|
||||||
if (!svr->bind_to_port(params.hostname, params.port)) {
|
bool was_bound = false;
|
||||||
|
if (params.port == 0) {
|
||||||
|
int bound_port = svr->bind_to_any_port(params.hostname);
|
||||||
|
if ((was_bound = (bound_port >= 0))) {
|
||||||
|
params.port = bound_port;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
was_bound = svr->bind_to_port(params.hostname, params.port);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!was_bound) {
|
||||||
//LOG_ERROR("couldn't bind HTTP server socket", {
|
//LOG_ERROR("couldn't bind HTTP server socket", {
|
||||||
// {"hostname", params.hostname},
|
// {"hostname", params.hostname},
|
||||||
// {"port", params.port},
|
// {"port", params.port},
|
||||||
@ -3357,6 +3367,8 @@ int main(int argc, char ** argv) {
|
|||||||
clean_up();
|
clean_up();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// run the HTTP server in a thread
|
||||||
std::thread t([&]() { svr->listen_after_bind(); });
|
std::thread t([&]() { svr->listen_after_bind(); });
|
||||||
svr->wait_until_ready();
|
svr->wait_until_ready();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user