Repository navigation
Auto reload the controller dev server - #47
Merged
knuton merged 2 commits intoOct 28, 2020
Merged
Conversation
Previously, we had to manually stop and restart the server after each change. Dune accepts the `--watch` parameter, But it does not work with `--exec`, see ocaml/dune#2934. There is a workaround, using an alias, see ocaml/dune#2934 (comment). `dune build --watch @install @run --profile release -j1 --no-buffer` `server/dune` ``` (alias (name run) (action (run ./run-server))) ``` `run-server` ```bash cd ../../.. function finish { # Stop the running server lsof -i tcp:3333 | grep LISTEN | awk '{print $2}' | xargs kill } trap finish EXIT finish ./_build/install/default/bin/playos-controller ``` But there are 2 problems: 1. the server is started whenever the build succeeded or not. We could find a solution to inquire whether the build ran successfully or not in the `run-server` command. 2. A long output is appended after the error message, requiring to scroll to see the error message. There may also be a solution to this problem. It seems simpler to stick to our custom solution at this point.
knuton
reviewed
Oct 27, 2020
| if [ "$?" -eq 0 ]; then | ||
|
|
||
| # Kill already running server if any | ||
| lsof -i tcp:3333 | grep LISTEN | awk '{print $2}' | xargs kill 2>/dev/null |
Member
There was a problem hiding this comment.
Is the killing put behind this guard on purpose? It has the effect of letting the previously built server run if the new build fails, which I think could lead to confusion.
Author
There was a problem hiding this comment.
Exact, fixed with 5c00e1e. I also improved the initial launch of bin/dev-server, after a dune clean.
knuton
approved these changes
Oct 28, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Previously, we had to manually stop and restart the server after
each change.
Dune accepts the
--watchparameter, But it does not work with--exec, see ocaml/dune#2934.There is a workaround, using an alias, see ocaml/dune#2934 (comment).
dune build --watch @install @run --profile release -j1 --no-bufferserver/dunerun-serverBut there are 2 problems:
the server is started whenever the build succeeded or not. We could
find a solution to inquire whether the build ran successfully or not in
the
run-servercommand.A long output is appended after the error message, requiring
to scroll to see the error message. There may also be a solution to this
problem.
It seems simpler to stick to our custom solution at this point.
Checklist
[ ] Changelog updated[ ] Code documented