Debian Codegraph @

/

debian rust-listenfd 1.0.2-1debian librust-listenfd-dev debian librust-listenfd+default-dev debian librust-listenfd-1-dev debian librust-listenfd-1+default-dev debian librust-listenfd-1.0-dev debian librust-listenfd-1.0+default-dev debian librust-listenfd-1.0.2-dev debian librust-listenfd-1.0.2+default-dev debianjsonmakemakefilemarkdownrustshelltomlyaml 26 files · 56 symbols
View dependency graph

Depends on

  • dh-cargo (dh-sequence-cargo)
  • rust-libc (librust-libc-0.2+default-dev)
  • cargo, debhelper-compat, libstd-rust-dev, rustc
README (full)

listenfd

Crates.io License rustc 1.42.0 Documentation

listenfd is a crate that provides support for working with externally managed and passed file descriptors. This lets you work with systems that support socket activation or similar.

Currently this supports systemd (including systemd-socket-activate) on Unix and systemfd on Unix and Windows. systemfd is very convenient in combination with cargo-watch for development purposes whereas systemd is useful for production deployments on linux.

Example

use listenfd::ListenFd;

let mut listenfd = ListenFd::from_env();
let mut server = make_a_server();

// if we are given a tcp listener on listen fd 0, we use that one
server = if let Some(listener) = listenfd.take_tcp_listener(0)? {
    server.listen(listener)
// otherwise fall back to local listening
} else {
    server.bind("127.0.0.1:3000")?
};

You can then use this with cargo watch and systemfd:

$ cargo install systemfd cargo-watch
systemfd --no-pid -s http::3000 -- cargo watch -x run

Now systemfd will open the socket and keep it open. cargo watch will recompile the code on demand and the server will pick up the socket that systemfd opened. No more connection resets.

License and Links

dir .github/
dir debian/
dir examples/
dir src/
file .cargo_vcs_info.json
file .gitignore
file CHANGELOG.md
file Cargo.lock
file Cargo.lock.msrv
file Cargo.toml
file Cargo.toml.orig
file LICENSE
file Makefile
file README.md