Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
POC: using
cargo watch
to restart the development server on changes!RnD Card
You'll need to install
cargo-make
,cargo-watch
and (maybe: see below)systemfd
globally:To now start the backend in watch mode, from the
backend
dir:Or, from the repo root:
This starts two process in parallel:
watch_build
watches for any changes in our Rust source code, and executescargo build
. When the build is finished (and it compiled correctly), it creates a.trigger
file.trigger_server_start
watches for changes on this.trigger
file, and restarts the server. This means the current version of the API remains available until the new version is compiled, and the restart after trigger is fairly quick.About the packages:
cargo-make
: manages the scriptscargo-watch
: watches for file changes, and executes provided commandssystemfd
: opens sockets and passes them to another process, allowing that process to restart itself without dropping connectionscargo-watch
stops the existing server before starting the new version. There's a couple seconds of downtime, and we can get dropped requests in that time.systemfd
spawns a socket that our Rust server can then bind to, meaning we avoid the request-dropping. It keeps the endpoint alive until the new server is ready... i.e. the request hangs for the restart time, rather than returning and error.Error: Couldn't connect to server
for a second or two?cargo make watch_with_downtime
(not using thesystemfd
stuff) so please try this out and let me know your thoughts!systemfd
way, I also need to figure out how to get the port from the configuration into the makefile? Have hardcoded 4007 for now...