Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Build a Smaller Watchexec

Rebuild the event-to-process contract, not a thin wrapper around notify.

What are we preserving?

  • concurrent event producers and bounded admission;
  • filtering plus trailing-edge debounce;
  • urgent lifecycle priority;
  • one serialized action policy;
  • a task-owned child state machine;
  • start, signal, restart, queued run, and graceful stop;
  • explicit recoverable-versus-fatal errors;
  • joined shutdown.

Reconstruction stages

  1. Model Event, Priority, and a bounded input channel; use synthetic events.
  2. Implement filter-then-debounce and test that urgent events flush immediately.
  3. Give an action callback an immutable event batch and return an Outcome.
  4. Build one supervisor task around tokio::process::Command and a control enum.
  5. Add busy policies: ignore, signal, restart, or one coalesced queued run.
  6. Add signal-then-deadline-then-kill, always awaiting the child afterward.
  7. Add multiple jobs, runtime error reporting, and structured task joining.
  8. Only then connect notify and platform process groups.

Production Watchexec still supplies portable watchers, ignore-file discovery, keyboard and OS signal sources, rich event tags, dynamic configuration, environment emission, process wrapping, shell interpretation, diagnostics, and many platform-specific failure paths.