shuttle
shuttle copied to clipboard
Add `--watch` flag to `shuttle run` (auto reload)
The cargo shuttle run command is used to create a local deployment of a project for testing.
On making changes to the code of services, the only way to have the diff rolled out to the local deployment is to exit the run command and restart it.
It'd be nice to have a --watch flag added to shuttle run so that periodically we poll for a diff in source, and roll out the change without exiting.
Any suggestions/strategies on how to implement this? Thanks
I'm using cargo watch -x "shuttle run" -i Cargo.lock in order to get this behavior.
I want help with watchexec configuration. There aren't many examples out there to take inspiration from
Since 0.12, you can simply do cargo watch -x 'shuttle run'.
Happy to take this one if it's still deemed necessary? Seems like --watch is a bit more user friendly to me.
@jmwill86 Do you envision encapsulating cargo watch or implementing file watching "from scratch"? I would not consider it worth putting effort into mimicking/wrapping cargo watch since it is already a great tool.
watchexec mentioned above seems like it could be a good choice, I'm not opposed to using cargo watch if the work there is already done or it avoids boilerplate though.
Quick update. I'm in a new job currently, so I'm struggling to get time to implement this. I'll still do it at some point hopefully, but if someone else wants to take it then feel free, I don't want to hold back any progress here.
To clarify my stance on this:
IMO if a user wants hot reloads they can install cargo-watch (or watchexec) separately, so that it can be used as the general purpose tool it already is (for shuttle and other projects). The Shuttle docs could simply recommend users to install it and show the recommended commands. This, and other good tips, could be on a "Development tips" page.
@jmwill86 is the syntax of cargo watch -x 'shuttle run' the main reason you want it as a flag instead? Also, does your idea involve calling the user's installed cargo-watch/watchexec or use watchexec as a library?
The docs has a section on how to use auto reloading for backend and some frontends https://docs.shuttle.rs/getting-started/local-run#development-tips
cargo watch -x "shuttle run" -i Cargo.lock
This worked well for me, but it might be nice if shuttle supported a way to do this "out of the box".