8000 Allow `launch_on` with a Tokio Unix socket listener · Issue #2933 · rwf2/Rocket · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow launch_on with a Tokio Unix socket listener #2933

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

Open
2 tasks done
thetorpedodog opened this issue Apr 20, 2025 · 1 comment
Open
2 tasks done

Allow launch_on with a Tokio Unix socket listener #2933

thetorpedodog opened this issue Apr 20, 2025 · 1 comment
Labels
request Request for new functionality

Comments

@thetorpedodog
Copy link

What's missing?

Currently (v0.6 development), you can pass a Tokio TcpListener to launch_on. However, you can’t do the same thing with a UnixListener. Doing this would bring parity between Rocket’s internal support for unix:/path/to/whatever–style addresses and what launch_on accepts.

This would make it possible for external users (e.g., me) to use Rocket with systemd socket activation, where an already-bound socket is passed into the process. Note that this already works with TCP sockets—you can construct a tokio::net::TcpListener from the passed-in socket and provide it to Rocket.

This is a continuation of #545 and #2485.

Ideal Solution

Unlike the TcpListener type, which is directly used from Tokio, there is a custom UnixListener struct which handles creation of the socket file, locking, etc.

To this we add a From<tokio::net::UnixListener implementation which simply takes ownership of the Tokio listener, and make the path also Optional (so we don’t try to remove it upon drop).

impl From<tokio::net::UnixListener> for UnixListener {
    fn from(listener: tokio::net::UnixListener) {
        Self{ path: None, lock: None, listener }
    }
}

Why can't this be implemented outside of Rocket?

There is no way to pass your own Unix socket into Rocket otherwise.

Are there workarounds usable today?

No response

Alternative Solutions

No response

Additional Context

No response

System Checks

  • I do not believe that this feature can or should be implemented outside of Rocket.
  • I was unable to find a previous request for this feature.
@thetorpedodog thetorpedodog added the request Request for new functionality label Apr 20, 2025
@thetorpedodog
Copy link
Author

An alternate, though broadly equivalent, solution would be to rename Rocket’s special UnixListener to something like OwnedUnixListener or ManagedUnixListener and add an impl Listener for UnixListener block (now referring to Tokio). I kind of like this more, since it discerns between Tokio UnixListeners and UnixListeners we bind and own ourselves and have to clean up, though it does have further-reaching code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request Request for new functionality
Projects
None yet
Development

No branches or pull requests

1 participant
0