Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 25 additions & 41 deletions lib/daemon_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -464,27 +464,7 @@ def abort_start(pid:, is_direct_child:)
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
wait_for_aborted_process(pid:, is_direct_child:)
end
end
rescue Timeout::Error
Expand All @@ -494,28 +474,32 @@ def abort_start(pid:, is_direct_child:)
end

allow_timeout do
if is_direct_child
begin
debug "Waiting directly for process #{pid}"
Process.waitpid(pid)
rescue SystemCallError
end
wait_for_aborted_process(pid:, is_direct_child:)
end
end
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
def wait_for_aborted_process(pid:, is_direct_child:)
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

Expand Down