Hot reload
Rust compiles to a native binary, so there is no module replacement in a running process. What you can have is recompiling and restarting the application every time you save a file:
bash
cargo install cargo-watch # only once
corvis start --watchcorvis start --watch runs cargo watch -x run: it watches the project, recompiles when a file changes and launches the server again. Without the CLI, the equivalent command is the same cargo watch -x run.
Compile times
In medium-sized projects, the time of each restart is set by compilation. Some measures that help:
- Compile in debug mode during development (what
corvis startdoes); leave--releasefor production. - Split the project into crates inside a workspace: Cargo only recompiles the ones that changed.
- Keep an eye on the
targetfolder: each configuration (debug, release, tests) generates its own copy of the dependencies and can take up several GB.
State between restarts
Each restart creates a new process, so in-memory state (caches, sessions, WebSocket connections) is lost. WebSocket clients must reconnect; the examples/tertulia client does it on its own.