Skip to content

Commit 171bbf7

Browse files
authored
autoreload: add some notes about systemfd/listenfd (#696)
1 parent cec1359 commit 171bbf7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/autoreload.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ watchexec -w src -r cargo run
2020

2121
## Historical Note
2222

23-
An old version of this page recommended using a combination of systemfd and listenfd, but this has many gotchas and was difficult to integrate properly, especially when part of a broader development workflow. We consider [`watchexec`] to be sufficient for auto-reloading purposes.
23+
An old version of this page recommended using a combination of [`systemfd`] and [`listenfd`], but this has many gotchas and was difficult to integrate properly, especially when part of a broader development workflow. We consider [`watchexec`] to be sufficient for auto-reloading purposes.
24+
25+
If you still want to use [`systemfd`]/[`listenfd`], keep these common gotchas in mind:
26+
27+
- It requires code changes to accept an externally provided listener, so you need extra setup (and often an extra dependency) in your server code instead of a simple `bind`.
28+
- When a watcher process sits between `systemfd` and your server (for example, `cargo watch` or `watchexec`), you must disable the `LISTEN_PID` check (for example, `systemfd --no-pid`). Otherwise `listenfd` ignores the passed socket and your app falls back to binding a port that is already in use.
29+
- systemd socket activation itself is Linux-only. [`systemfd`] emulates socket passing on macOS/Linux and uses a custom protocol on Windows, so behavior differs across platforms.
30+
- Because [`systemfd`] keeps the listening socket open while a rebuild happens, the port can look "open" even when your app is not running yet; requests may hang during slow or failed rebuilds.
2431

2532
[`watchexec`]: https://github.com/watchexec/watchexec
33+
[`listenfd`]: https://github.com/mitsuhiko/listenfd
34+
[`systemfd`]: https://github.com/mitsuhiko/systemfd

0 commit comments

Comments
 (0)