-
Notifications
You must be signed in to change notification settings - Fork 13
Reduce redundancy in #abort_start code #19
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e945b9d
DRY abort_start
CamJN d70878f
Merge branch 'master' into PR/DRY_abort_start
FooBarWidget 749859d
revert unequivalent process kill code section
FooBarWidget e427800
Merge branch 'master' into PR/DRY_abort_start
FooBarWidget e76943a
address comments
FooBarWidget 9de68fe
Merge branch 'master' into PR/DRY_abort_start
FooBarWidget File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -455,44 +455,10 @@ def daemonization_timed_out(pid) | |
|
|
||
| # Aborts a daemon that we tried to start, but timed out. | ||
| def abort_start(pid:, is_direct_child:) | ||
| begin | ||
| debug "Killing process #{pid}" | ||
| Process.kill("SIGTERM", pid) | ||
| rescue SystemCallError | ||
| end | ||
|
|
||
| begin | ||
| timeoutable(@start_abort_timeout) do | ||
| allow_timeout do | ||
| if is_direct_child | ||
| begin | ||
| debug "Waiting directly for process #{pid}" | ||
| Process.waitpid(pid) | ||
| rescue SystemCallError | ||
| end | ||
|
|
||
| # The daemon may have: | ||
| # 1. Written a PID file before forking. We delete this PID file. | ||
| # -OR- | ||
| # 2. It might have forked (and written a PID file) right before | ||
| # we terminated it. We'll want the fork to stay alive rather | ||
| # than going through the (complicated) trouble of killing it. | ||
| # Don't touch the PID file. | ||
| pid2 = read_pid_file | ||
| debug "PID file contains #{pid2.inspect}" | ||
| delete_pid_file if pid == pid2 | ||
| else | ||
| debug "Waiting until daemon is no longer running" | ||
| wait_until { !daemon_is_running? } | ||
| end | ||
| end | ||
| end | ||
| rescue Timeout::Error | ||
| begin | ||
| Process.kill("SIGKILL", pid) | ||
| rescue SystemCallError | ||
| end | ||
| debug "Killing process #{pid}" | ||
| Process.kill("SIGTERM", pid) | ||
|
|
||
| block = proc do | ||
|
||
| allow_timeout do | ||
| if is_direct_child | ||
| begin | ||
|
|
@@ -517,6 +483,12 @@ def abort_start(pid:, is_direct_child:) | |
| end | ||
| end | ||
| end | ||
|
|
||
| timeoutable(@start_abort_timeout, &block) | ||
| rescue Timeout::Error | ||
| Process.kill("SIGKILL", pid) | ||
| block.call | ||
| rescue SystemCallError | ||
| end | ||
|
|
||
| def save_log_file_information | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.