Skip to content
Helper crate to work with systemd/catflap socket activation
Rust Makefile
Branch: master
Clone or download
Latest commit 89a37b3 Oct 24, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
src fix: Fixed format Oct 24, 2018
.gitignore Initial commit May 17, 2018
Cargo.toml 0.3.3 May 20, 2018
Makefile fix: Fixed format Oct 24, 2018 Update README ListenFdManager -> ListenFd Oct 24, 2018
appveyor.yml fix appveyor script May 17, 2018


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 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.


extern crate listenfd;
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)? {
// otherwise fall back to local listening
} else {

You can then use this with cargo watch and systemfd:

$ cargo install systemfd cargo-watch
systemfd --no-pid -p 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.

You can’t perform that action at this time.