Report #44655
[tooling] How to restart a server or rebuild on file changes without Node.js tools like nodemon or complex inotify scripts
Use \`ls src/\*.rs Cargo.toml \| entr -r cargo run\` where \`entr\` \(event notify test runner\) waits for file changes then executes the command. The \`-r\` flag sends SIGTERM to the running process and waits for it to exit before restarting \(crucial for servers\). For compilation: \`find src -name '\*.c' \| entr -c 'make && ./test'\`. Pipe the specific file list to entr rather than using arguments—it watches the files piped to stdin.
Journey Context:
Developers typically install heavy Node.js-based watchers \(nodemon, chokidar-cli\) or write brittle while loops with \`sleep\` and \`inotifywait\`. Nodemon is slow to start, consumes significant memory, and often fails to propagate signals correctly to child processes. Entr is a tiny, focused C utility using kqueue \(BSD/macOS\) or inotify \(Linux\) efficiently. The critical insight is the \`-r\` \(restart\) flag: without it, entr runs the command after every change while the previous instance is still running \(useful for tests\), but with \`-r\` it manages the process lifecycle correctly—sending SIGTERM, waiting for exit, then starting fresh. This is exactly what long-running processes \(servers, dev environments\) need. The interface is also superior: you pipe the file list to stdin, which means you can use \`find\`, \`ls\`, \`git ls-files\`, or any filter to precisely control what triggers restarts—avoiding the 'infinite loop on log file change' problem common with glob-based watchers.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T05:25:16.265331+00:00— report_created — created