-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
Recommend watchexec for live_reload example #81
Comments
I haven't looked at this, but shouldn't we be able to use |
@tcoopman I think the reason have been explained in live-reload example. dune —watch doesn’t kill the server process |
ok, just found the issue on dune: ocaml/dune#2934 |
Also cc @tmattio, in case watchexec is good for the example script in dream-liverelaod. |
From #139 (comment), a command line for killing any listening Dream processes (seemingly using port 5000) and restarting:
|
It seems that the dune limitation is confined to
and then I run it with |
Does this automatically kill a running |
So far in my experience, yes. I've not used fswatch at all. |
Can close because dune exec -w is now available |
Thanks! I just tried this out and it seems to kill the running server now -- very nice! We probably need to update the watch example. |
In case it's useful, I created a demo of a live reload workflow using Dune's watch mode for executables at https://github.com/tmattio/dune-watchmode-livereload-demo. |
Very nice! With Dune's server-killing watch support and the upcoming Dune 3.8.0 fix that will print a newline |
That is, a newline after build output and before running the executable being built. |
Sure, I'm happy to open a PR for that 🙂 |
I took a look at the dream-livereload repo again, and with all these improvements, we can get rid of the shell script completely. We can also combine the route and middleware into just a middleware that both injects the script, and intercepts requests by matching on the target (as long as we document that). That would make usage very easy, and maintain the "one feature/aspect is activated in one place" goal that Dream is aiming for. It would introduce Markup.ml and Lambda Soup dependency to Dream, but both of those are "pure" and not more heavy than, say, the base Caqti dependency that we already have (which is also "pure," the other Caqti plugins introduce system dependencies on database libs). |
The middleware can probably have an optional |
The only wrinkle I see is that the middleware probably needs to respect the site prefix, but I would merge a PR without that. That part of the router probably needs to be factored out at this point, then, so that middlewares like this can reuse that code. |
Actually, scratch |
All good points, thanks! I'll keep them in mind before making the PR. Re. the
Or having if-else statements with Passing |
I do agree with that, but I wanted to stick with There is one ergonomics counterargument to @@ middleware_1 ?enabled:is_development
@@ middleware_2 ?enabled:is_development
@@ middleware_3 ?enabled:is_development though I'm not sure yet :) But it does seem more maintainable even for me as the user to have the condition in one place, and the slightly awkward but still composable approach allows that. Although that's also possible if we adopt both approaches. In summary, it seems to me like it's not clear that |
I guess this can be closed? |
I have been trying several solution over the past few days and so far, watchexec (https://github.com/watchexec/watchexec) is the most reliable one and it’s fast.
fswatch + custom script in the current example keep failing to kill the process, I have to kill it manually several times
Example:
The text was updated successfully, but these errors were encountered: