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
Support for Linux's abstract sockets #2526
Comments
Nothing against including it. What's the use case? |
I think our use case is using a unix socket with a read-only file system. |
@nerdrew What have you tried specifically in order to get puma to try to listen to a unix socket in an abstract namespace? I'm kinda curious what the API would look like for us to implement it. I think the most straightforward way to allow users to use abstract sockets would probably be something like # abstract_socket.rb
bind "unix://\0puma.sock" bundle exec ruby -Ilib bin/puma -C abstract_socket.rb test/rackup/hello.ru The literal leading NUL byte seems like it'd be accepted by Ruby's UnixSocket according to the discussion in the issue on the Ruby bug tracker. That fails in puma right now with
From searching around, it seems like it's a common idiom to accept puma -b unix://@puma.sock Does that look like about what you'd expect? |
Yup, the leading server = Puma::Server.new ->(env) {
if env['PATH_INFO'] == '/ready'
response
else
[404, {}, ["Not found.\n"]]
end
}
server.add_unix_listener(socket_path.sub(/^@/, "\0"))
server.run Error:
|
That makes sense. Are you interested in open a PR for this feature yourself? Otherwise, we can leave the issue up until another contributor has the time to commit to it. |
I got this working with minimal changes to the code in PR #2519 (using Windows WSL2/Ubuntu), which uses the 'new test framework'. Both hot & phased restarts also worked. Since it has 'central code' for creating both servers and clients, it's relatively easy (but not trivial) to make the change. Currently, |
Hmmm, does it make sense to add a whole new option? Is an abstract unix socket that different from a filesystem-backed one? |
Sorry, ignore that, I was speaking of CI testing code, not Puma runtime code. Puma runtime code should treat a UnixSocket bind starting with '@' as abstract, that's the only change needed. But, I'm not sure about abstract UnixSocket binding and systemd, etc. |
That's kinda what I figured but just wanted to make it clear 👍 |
* Support Linux's abstract sockets Closes #2526 * Add two simple UNIXSocket tests
* Support Linux's abstract sockets Closes puma#2526 * Add two simple UNIXSocket tests
Linux supports listening on an abstract socket that is not represented by a path on the filesystem (https://man7.org/linux/man-pages/man7/unix.7.html). I think ruby's
UNIXSocket
support abstract sockets, but some of theFile.exist?
type checks in puma fail because abstract sockets start with a NUL byte"\0"
. Thoughts on supporting abstract sockets?The text was updated successfully, but these errors were encountered: