1
0
mirror of https://github.com/actix/actix-website synced 2025-02-09 23:05:37 +01:00

docs: rewrite autoreload recommending watchexec (#530) (#541)

This commit is contained in:
Simon Barth 2025-02-03 18:19:24 +00:00 committed by GitHub
parent dd35a7c8bc
commit df52fdc473
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,14 +4,22 @@ title: Auto-Reloading
# Auto-Reloading Development Server
During development it can be very handy to have cargo automatically recompile the code on changes. This can be accomplished very easily by using [`cargo-watch`].
During development it can be very handy to have cargo automatically recompile the code on changes. This can be accomplished very easily by using [`watchexec`].
The following command runs/restarts `cargo run` every time a file with the `rs` extension changes inside the current directory (including subdirectories):
```sh
cargo watch -x run
watchexec -e rs -r cargo run
```
If you want to watch all files in a specific directory, you can use the the `-w` argument:
```sh
watchexec -w src -r cargo run
```
## Historical Note
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 [`cargo-watch`] to be sufficient for auto-reloading purposes.
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.
[`cargo-watch`]: https://github.com/passcod/cargo-watch
[`watchexec`]: https://github.com/watchexec/watchexec