mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
Do not reset cli events when in cluster mode
This commit is contained in:
parent
12c4c2d222
commit
93e13af665
2 changed files with 21 additions and 18 deletions
|
@ -491,7 +491,7 @@ module Puma
|
|||
set_rack_environment
|
||||
|
||||
if clustered?
|
||||
@events = PidEvents.new STDOUT, STDERR
|
||||
@events.formatter = Events::PidFormatter.new
|
||||
@options[:logger] = @events
|
||||
|
||||
@runner = Cluster.new(self)
|
||||
|
|
|
@ -8,12 +8,24 @@ module Puma
|
|||
# The methods available are the events that the Server fires.
|
||||
#
|
||||
class Events
|
||||
class DefaultFormatter
|
||||
def call(str)
|
||||
str
|
||||
end
|
||||
end
|
||||
|
||||
class PidFormatter
|
||||
def call(str)
|
||||
"[#{$$}] #{str}"
|
||||
end
|
||||
end
|
||||
|
||||
include Const
|
||||
|
||||
# Create an Events object that prints to +stdout+ and +stderr+.
|
||||
#
|
||||
def initialize(stdout, stderr)
|
||||
@formatter = DefaultFormatter.new
|
||||
@stdout = stdout
|
||||
@stderr = stderr
|
||||
|
||||
|
@ -28,6 +40,7 @@ module Puma
|
|||
end
|
||||
|
||||
attr_reader :stdout, :stderr
|
||||
attr_accessor :formatter
|
||||
|
||||
# Fire callbacks for the named hook
|
||||
#
|
||||
|
@ -52,11 +65,11 @@ module Puma
|
|||
# Write +str+ to +@stdout+
|
||||
#
|
||||
def log(str)
|
||||
@stdout.puts str
|
||||
@stdout.puts format(str)
|
||||
end
|
||||
|
||||
def write(str)
|
||||
@stdout.write str
|
||||
@stdout.write format(str)
|
||||
end
|
||||
|
||||
def debug(str)
|
||||
|
@ -66,10 +79,14 @@ module Puma
|
|||
# Write +str+ to +@stderr+
|
||||
#
|
||||
def error(str)
|
||||
@stderr.puts "ERROR: #{str}"
|
||||
@stderr.puts format("ERROR: #{str}")
|
||||
exit 1
|
||||
end
|
||||
|
||||
def format(str)
|
||||
formatter.call(str)
|
||||
end
|
||||
|
||||
# An HTTP parse error has occured.
|
||||
# +server+ is the Server object, +env+ the request, and +error+ a
|
||||
# parsing exception.
|
||||
|
@ -113,18 +130,4 @@ module Puma
|
|||
Events.new $stdout, $stderr
|
||||
end
|
||||
end
|
||||
|
||||
class PidEvents < Events
|
||||
def log(str)
|
||||
super "[#{$$}] #{str}"
|
||||
end
|
||||
|
||||
def write(str)
|
||||
super "[#{$$}] #{str}"
|
||||
end
|
||||
|
||||
def error(str)
|
||||
super "[#{$$}] #{str}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue