Skip to content

wasmtime serve: Allow inheriting sockets from system manager - #14294

Open
simolus3 wants to merge 5 commits into
bytecodealliance:mainfrom
simolus3:serve-listenfds
Open

wasmtime serve: Allow inheriting sockets from system manager#14294
simolus3 wants to merge 5 commits into
bytecodealliance:mainfrom
simolus3:serve-listenfds

Conversation

@simolus3

@simolus3 simolus3 commented Sep 7, 2026

Copy link
Copy Markdown

This adds the --listenfd option to wasmtime serve. When it's enabled and wasmtime is launched from a systemd socket unit, we use the socket created by systemd instead of creating a new one. The main benefit of this is efficiency: The wasmtime process is only started when the first client connects. Additionally, this allows sandboxing the process in a private network namespace (since the only socket it will use is inherited).

To test this, the systemfd utility may be convenient:

systemfd -s http::5000 -- cargo run -- serve file.wasm --listenfd

This also removes the old -S listenfd option: The only place using that option was a check that errors when it's set.

Closes #14289. As suggested in that thread, I've also linked the used systemd protocol for this in a comment.

@simolus3
simolus3 requested review from a team as code owners September 7, 2026 20:56
@simolus3
simolus3 requested review from alexcrichton and pchickey and removed request for a team September 7, 2026 20:56
Comment thread src/commands/serve.rs
Comment thread src/commands/serve.rs Outdated
@github-actions github-actions Bot added the wasmtime:docs Issues related to Wasmtime's documentation label Sep 7, 2026
Comment thread src/commands/serve.rs Outdated
Comment thread src/commands/serve.rs Outdated
Comment thread src/commands/serve.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:docs Issues related to Wasmtime's documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restore listenfd suport for wasmtime serve

3 participants