Skip to main content

run_dev

Function run_dev 

Source
pub async fn run_dev(addr: &str) -> Result<()>
Expand description

Run the development server with automatic hot-reload.

§Behaviour

  1. Spawns cargo run -- serve --addr <addr> as a child process.
  2. Watches ./src for Create, Modify, or Remove events via the notify crate.
  3. On change: kills the running child, waits for it to exit, drains any burst of additional events (300 ms debounce), and re-spawns.
  4. If the child exits on its own (e.g. compile error), the loop waits for the next file-change event before attempting to restart, avoiding a tight CPU-burning restart loop.

§Limitations

Because Rust is AOT-compiled, “hot reload” here means recompilation and process restart — not in-process code swapping. Use RUST_LOG=info for structured log output during development.