Auto reload server when change source code for get new changes in development mode. What are you think about it?
Live reloading is a wonderful feature. However, supporting it in a compiled language is rather difficult.
There is some work done in making it possible to do dynamic loading in Rust, but again, this kind of thing is very difficult in a compiled system, and therefore the current state of this is not mature enough to include in Rocket, I think. more information.
So Auto Reload in case of source code changes is probably not viable right now, but what about reloading the templates automatically? Is it possible somehow for Tera templates for example?
See #163 regarding the templates reloading
I think something like per-route live reloading would be absolutely incredible, but given the complexities involved and the nature of Rust, is unlikely to ever happen. Nonetheless, incremental compilation is actively being worked on by the Rust team, so simply recompiling and restarting should eventually be plenty fast. Coupled with something like watchexec as mentioned in #163, and you'll have something very close to "auto reload".
For templating specifically, I think it would be nice if Rocket could reload templates automatically during development. Further, I think it's absolutely possible, and quite simple, in fact, given the new fairings and the new Template implementation in master. We should see this in the not-too-distant future. We can have that discussion in #163.
Hello, in case anyone comes across this issue like I did, there's a pretty simple, "Unixy" workaround that will reload the development server whenever a file changes:
fd -g "*.rs" | entr -r cargo run
For me the following shell code works: find src -type f | entr -r cargo run
I use cargo-watch cargo watch -x run.
For posterity, note that since this issue, Rocket has gained the ability to automatically live-reload templates. This is enabled by default when the application is compiled in debug mode. There is no need to use external tools if the desire is to see changes to templates as they happen. If code changes occur elsewhere, however, the suggestion to use tools like cargo-watch and watchexec remain valid.
Most helpful comment
Hello, in case anyone comes across this issue like I did, there's a pretty simple, "Unixy" workaround that will reload the development server whenever a file changes: