Support socket activation for mdbook serve#3093
Open
Ericson2314 wants to merge 1 commit intorust-lang:masterfrom
Open
Support socket activation for mdbook serve#3093Ericson2314 wants to merge 1 commit intorust-lang:masterfrom
mdbook serve#3093Ericson2314 wants to merge 1 commit intorust-lang:masterfrom
Conversation
a8da753 to
67b5b46
Compare
Add a `--socket-activate` flag that adopts a pre-bound TCP listener from `LISTEN_FDS` instead of binding a new one. This allows process managers like foreman (with Socketfile support) or systemd to own the socket, so it survives server restarts. Three modes: - `--socket-activate`: require a passed-in socket, fail if absent - `--port N` / `--hostname H`: always bind, ignore `LISTEN_FDS` - Neither: try `LISTEN_FDS` first, fall back to binding the default The listener is now bound in the main thread before spawning the server, so the actual address is always known for logging and `--open`. Also parse `--port` as `u16` at arg-parse time instead of leaving it as a string. Socket activation is normally associated with systemd. And indeed, it would be peculiar to wire up this development command with systemd, but it is also used in other contexts more appropriate to this command, like https://github.com/mitsuhiko/systemfd, a development tool. From a Capsicum/WASI perspective, it also is generally better when tools can consume resources provided by a more privileged caller, rather than having to open them themselves. For these reasons, I think everything should support socket-activation.
67b5b46 to
a25052e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
--socket-activateflag that adopts a pre-bound TCP listener fromLISTEN_FDSinstead of binding a new one. This allows process managers like foreman (with Socketfile support) or systemd to own the socket, so it survives server restarts.Three modes:
--socket-activate: require a passed-in socket, fail if absent--port N/--hostname H: always bind, ignoreLISTEN_FDSLISTEN_FDSfirst, fall back to binding the defaultThe listener is now bound in the main thread before spawning the server, so the actual address is always known for logging and
--open.Also parse
--portasu16at arg-parse time instead of leaving it as a string.Socket activation is normally associated with systemd. And indeed, it would be peculiar to wire up this development command with systemd, but it is also used in other contexts more appropriate to this command, like https://github.com/mitsuhiko/systemfd, a development tool. From a Capsicum/WASI perspective, it also is generally better when tools can consume resources provided by a more privileged caller, rather than having to open them themselves. For these reasons, I think everything should support socket-activation.