shuttle icon indicating copy to clipboard operation
shuttle copied to clipboard

Add `--watch` flag to `shuttle run` (auto reload)

Open brokad opened this issue 3 years ago • 11 comments

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.

brokad avatar Nov 29 '22 12:11 brokad

Any suggestions/strategies on how to implement this? Thanks

gautamprikshit1 avatar Jan 10 '23 15:01 gautamprikshit1

I'm using cargo watch -x "shuttle run" -i Cargo.lock in order to get this behavior.

robertohuertasm avatar Jan 17 '23 18:01 robertohuertasm

I want help with watchexec configuration. There aren't many examples out there to take inspiration from

gautamprikshit1 avatar Jan 30 '23 16:01 gautamprikshit1

Since 0.12, you can simply do cargo watch -x 'shuttle run'.

jonaro00 avatar Mar 21 '23 22:03 jonaro00

Happy to take this one if it's still deemed necessary? Seems like --watch is a bit more user friendly to me.

jmwill86 avatar Mar 22 '23 16:03 jmwill86

@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.

jonaro00 avatar Mar 22 '23 17:03 jonaro00

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.

jmwill86 avatar Mar 22 '23 22:03 jmwill86

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.

jmwill86 avatar May 12 '23 14:05 jmwill86

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?

jonaro00 avatar May 13 '23 20:05 jonaro00

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

jonaro00 avatar Oct 06 '23 12:10 jonaro00

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".

hamirmahal avatar Dec 02 '23 01:12 hamirmahal