Skip to content

When listening on a unix domain socket don't print http:// and port #14180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2025

Conversation

ericcurtin
Copy link
Collaborator

Instead show something like this:

main: server is listening on file.sock - starting the main loop

@ericcurtin
Copy link
Collaborator Author

ericcurtin commented Jun 14, 2025

When investigating launching as a unix domain socket via something like "--host file.sock". I notice we were printing:

listening on http://file.sock:8080

@ericcurtin
Copy link
Collaborator Author

A question also... When we terminate llama-server running as a socket, we don't delete the .sock file... Should we attempt to delete that on termination?

@ericcurtin
Copy link
Collaborator Author

Forgot a : here will add soon

Comment on lines 4964 to 4971
std::string full_url;
if (is_sock) {
full_url = params.hostname;
} else {
full_url = "http://" + params.hostname + ":" + std::to_string(params.port);
}

LOG_INF("%s: server is listening on %s - starting the main loop\n", __func__, full_url.c_str());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nits: I prefer the log code to be short, so something like this looks better:

    LOG_INF("%s: server is listening on %s - starting the main loop\n", __func__,
            is_sock ? params.hostname.c_str() : string_format("http://%s:%d", ...).c_str());

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also wondering now is http+unix:// a better prefix for the unix socket case

Copy link
Collaborator

@ngxson ngxson Jun 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will look weird for most users. trust me, more than 90% users out there don't even know what is a unix socket sorry misunderstood, I think just unix:// maybe enough?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also the URL won't get highlighted in some terminal UI unless it has http:// or https:// prefix (which allow ctrl+click to open on browser)

@ngxson
Copy link
Collaborator

ngxson commented Jun 14, 2025

A question also... When we terminate llama-server running as a socket, we don't delete the .sock file... Should we attempt to delete that on termination?

In my experience working with unix socket before, I usually has code to detect if the .sock file already exist on application startup. If it exists, delete before creating a new one.

The other way (delete upon termination) may fail if the app is killed for example.

Instead show something like this:

main: server is listening on file.sock - starting the main loop

Signed-off-by: Eric Curtin <[email protected]>
@ericcurtin
Copy link
Collaborator Author

All done anyway...

@ericcurtin
Copy link
Collaborator Author

And now that I think of it, if we are to make --host an option for both http:// or unix:// , what we should have done is something like, default to http:// if no protocol is specified, if it starts with unix:// it's a socket, if it starts with http:// it's http.

I don't know if it's too late to make the breaking change, a unix socket doesn't have to end in .sock

@ngxson
Copy link
Collaborator

ngxson commented Jun 15, 2025

I'm not the one who added this feature. I know unix sockets are not necessary having .sock. But my POV is that doing:

llama-server --host /some/place/llama.sock

Is more intuitive and easier to remember than:

llama-server --host /some/place/llama --unix-sock

It's just a minor UX. If you don't absolutely need the option without .sock, then a breaking change is redundant.

@ericcurtin
Copy link
Collaborator Author

Yeah... That's curl-style to a degree... I don't need this option anyway, I'm fine with .sock files :)

This PR is good to go for me at least

@ngxson ngxson merged commit cd355ed into master Jun 15, 2025
47 checks passed
@ericcurtin ericcurtin deleted the logging-fix-sock branch June 16, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants