New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support --watch
ing and auto-reloading binary upon changes
#21
Comments
I'm of the mind that this is outside the responsibility of the CLI, but I'm confused by the practicality of how it would work if Viceroy alone handled reloading of itself. To elaborate: Currently, we spawn an instance of Viceroy and within that execution flow we configure signal monitoring so that if the user issues a SIGINT or SIGTERM from their shell, then we catch it and kill the Viceroy process. This causes our call to So I imagine if Viceroy was to reload itself, then maybe that could use a particular signal or way of indicating to the CLI that a reload occurred for the CLI to then handle tracking the new (i.e. reloaded) Viceroy process so it can be stopped/cleaned-up whenever the user tries sending SIGINT/SIGTERM. Thoughts? Did any of what I said actual make any sense? 🙂 |
I suspect if Viceroy itself watched for Wasm changes, it would do so via fsnotify-type stuff and reload without restarting, rather than via user/process signals. If the CLI would do it, you'd probably do the same way, terminating and restarting the Viceroy child process without exiting the CLI parent process. Or maybe sending SIGHUP to Viceroy, if it understands that one. |
My gut feeling is this is functionality going to have to live in the CLI and not Viceroy if we want intelligent recompilation when a user saves a source file, as Viceroy doesn't and shouldn't know how to compile Wasm binaries from a magnitude of source languages - which the CLI does. Unless the only file being watched was the input binary to Viceroy (i.e. |
Just an FYI: In the JS ecosystem there are common tools for this kind of problem, the most popular being nodemon. This is how I am currently testing:
Nodemon automatically stops viceroy, runs a build and starts viceroy again each time a file is changed. |
The OS itself has a tool for this purpose: brew install fswatch
fswatch -o main.wasm | xargs -n1 viceroy Or, rebuild and re-launch when any file is changed. fswatch -or . | xargs -n1 sh -c 'fastly compute build && viceroy main.wasm' The sky's the limit 🌞 And, to give a bit of context to my previous comments, this why I tend to believe auto-reloading functionality is out of scope for tools like the CLI. The capability already exists in the OS, in a relatively straightforward form, and it works for everything! |
If the decision ends up being "put the watching capability into Viceroy" instead of the CLI (I don't have any preference here) it should be noted that the |
In a recent devrel/ECP sync meeting, the devrel team suggested that we go ahead and build a --watch flag for the CLI. This is being tracked as DEVEX-132 |
@triblondon does this mean the CLI would take care of this and that we should close this Viceroy ticket or is there work needed to be done in Viceroy to allow that functionality to be built into the CLI? |
The fastly cli now has a watch flag for this use-case, which I think means we can close this issue (https://developer.fastly.com/reference/cli/compute/serve/) |
As @JakeChampion has mentioned, the CLI already implements a |
During development, it's extremely convenient to have the service automatically reload on change. This is a tracking issue for implementing "watching" functionality.
Open Questions:
Originally reported by @tschneidereit; cc: @aturon, @peterbourgon.
The text was updated successfully, but these errors were encountered: