don't launch if server fails; kill server on exit #537#541
Merged
snoyberg merged 2 commits intoyesodweb:masterfrom May 2, 2016
simonmichael:master
Merged
don't launch if server fails; kill server on exit #537#541snoyberg merged 2 commits intoyesodweb:masterfrom simonmichael:master
snoyberg merged 2 commits intoyesodweb:masterfrom
simonmichael:master
Conversation
Member
|
I don't like relying on timing assumptions to make this work. Warp has a setting to run some code after initialization but before the main loop, which would allow handling this more robustly |
Contributor
Author
|
Great! PR updated. |
|
|
||
| -- launch the browser, after waiting until the server | ||
| -- signals that it's ready (or raises a startup exception) | ||
| let wait = do |
Member
There was a problem hiding this comment.
Why use an IORef here? If you use an MVar, then you can get blocking behavior and not need to worry about polling.
Contributor
Author
There was a problem hiding this comment.
Unfamiliarity/doubt about exception handling. It seems to work, PR updated...
Make the server thread and launch/monitor thread more aware of each other, using async. Now, we won't launch a browser until the server is ready to serve pages, and we won't launch it at all if the server fails to start. Also we make sure to terminate the server thread whenever the main thread terminates, eg from ctrl-c in GHCI.
Contributor
Author
|
Nice! I appreciate the review. |
Member
|
Alright, I'm out of ideas :). I'll wait for Travis to check before merging, but LGTM. |
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.
Make the server thread and launch/monitor thread more aware of each
other's failures, using async. Now if the server fails to start we won't
launch a browser. Also when the main thread terminates (eg from ctrl-c
in GHCI), we make sure the server thread does too. There is now a 0.1s
delay before launching the browser, which also helps ensure the server
is ready to serve.