Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions lib/puma/plugin/solid_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,9 @@ def puma_dead?

def log(...)
log_writer.log(...)
rescue Errno::EIO, Errno::EPIPE, Errno::EBADF
# The controlling terminal can disappear, or the output pipe close, before
# the monitor thread shuts down the child process. Keep shutdown moving
# even when logging cannot.
end
end
28 changes: 28 additions & 0 deletions test/unit/puma_plugin_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

require "test_helper"
require "puma/plugin/solid_queue"

class PumaPluginTest < ActiveSupport::TestCase
class ClosedOutputLogWriter
def initialize(error)
@error = error
end

def log(...)
raise @error
end
end

[ Errno::EIO, Errno::EPIPE, Errno::EBADF ].each do |error|
test "monitor still stops the process when shutdown logging fails with #{error}" do
plugin = Puma::Plugins.find("solid_queue").new
plugin.instance_variable_set(:@log_writer, ClosedOutputLogWriter.new(error))

plugin.stubs(:puma_dead?).returns(true)
Process.expects(:kill).with(:INT, Process.pid)

plugin.send(:monitor, :puma_dead?, "Detected Puma has gone away, stopping Solid Queue...")
end
end
end
Loading