Fix hangs when deleting / recreating project root with the same name#548
Open
misterbyrne wants to merge 4 commits intorails:mainfrom
Open
Fix hangs when deleting / recreating project root with the same name#548misterbyrne wants to merge 4 commits intorails:mainfrom
misterbyrne wants to merge 4 commits intorails:mainfrom
Conversation
|
(@rails-bot has picked a reviewer for you, use r? to override) |
misterbyrne
commented
Dec 4, 2017
| def alive? | ||
| @pid | ||
| return false if @pid.nil? | ||
| Process.getpgid(@pid) |
Contributor
Author
There was a problem hiding this comment.
This seems to be a reasonable way of determining whether a process with a certain pid exists.
misterbyrne
commented
Dec 4, 2017
| def wait_for_child_to_boot | ||
| timeout = 1 | ||
| loop do | ||
| break if IO.select([child], nil, nil, timeout) |
Contributor
Author
There was a problem hiding this comment.
The child process puts something on the socket to indicate that it's ready. Rather than simply wait forever as before (i.e. child.gets) we do the same, but check the process is still alive at 1 second intervals while doing so.
Contributor
Author
|
☝️ I'm not sure why CI failed. I tried a noop PR and that also failed :/ |
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.
Fix for issue detailed in #396 (comment)
If we have started a spring server, but the project root is deleted, the server can't successfully boot a child process. This is not recoverable. Even when the project is recreated, clients can also no longer communicate with the server because the socket path is derived from the project root (
Dir.pwd) which for the server process no longer exists.The proposed fix is to detect whenever a child cannot be started within a specific time frame - for whatever reason - rather than waiting indefinitely for the child to communicate with the
ApplicationManagerinstance. This raises an error. If any error occurs when attempting to create a child process, we just abort - which shuts down the server gracefully.This might not be a terribly common scenario, but I guess it can happen in real life - especially when people create throwaway projects to test stuff, or check out open source projects temporarily.