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
|
set_rack_environment
|
||||||
|
|
||||||
if clustered?
|
if clustered?
|
||||||
@events = PidEvents.new STDOUT, STDERR
|
@events.formatter = Events::PidFormatter.new
|
||||||
@options[:logger] = @events
|
@options[:logger] = @events
|
||||||
|
|
||||||
@runner = Cluster.new(self)
|
@runner = Cluster.new(self)
|
||||||
|
|
|
@ -8,12 +8,24 @@ module Puma
|
||||||
# The methods available are the events that the Server fires.
|
# The methods available are the events that the Server fires.
|
||||||
#
|
#
|
||||||
class Events
|
class Events
|
||||||
|
class DefaultFormatter
|
||||||
|
def call(str)
|
||||||
|
str
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
class PidFormatter
|
||||||
|
def call(str)
|
||||||
|
"[#{$$}] #{str}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
include Const
|
include Const
|
||||||
|
|
||||||
# Create an Events object that prints to +stdout+ and +stderr+.
|
# Create an Events object that prints to +stdout+ and +stderr+.
|
||||||
#
|
#
|
||||||
def initialize(stdout, stderr)
|
def initialize(stdout, stderr)
|
||||||
|
@formatter = DefaultFormatter.new
|
||||||
@stdout = stdout
|
@stdout = stdout
|
||||||
@stderr = stderr
|
@stderr = stderr
|
||||||
|
|
||||||
|
@ -28,6 +40,7 @@ module Puma
|
||||||
end
|
end
|
||||||
|
|
||||||
attr_reader :stdout, :stderr
|
attr_reader :stdout, :stderr
|
||||||
|
attr_accessor :formatter
|
||||||
|
|
||||||
# Fire callbacks for the named hook
|
# Fire callbacks for the named hook
|
||||||
#
|
#
|
||||||
|
@ -52,11 +65,11 @@ module Puma
|
||||||
# Write +str+ to +@stdout+
|
# Write +str+ to +@stdout+
|
||||||
#
|
#
|
||||||
def log(str)
|
def log(str)
|
||||||
@stdout.puts str
|
@stdout.puts format(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def write(str)
|
def write(str)
|
||||||
@stdout.write str
|
@stdout.write format(str)
|
||||||
end
|
end
|
||||||
|
|
||||||
def debug(str)
|
def debug(str)
|
||||||
|
@ -66,10 +79,14 @@ module Puma
|
||||||
# Write +str+ to +@stderr+
|
# Write +str+ to +@stderr+
|
||||||
#
|
#
|
||||||
def error(str)
|
def error(str)
|
||||||
@stderr.puts "ERROR: #{str}"
|
@stderr.puts format("ERROR: #{str}")
|
||||||
exit 1
|
exit 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def format(str)
|
||||||
|
formatter.call(str)
|
||||||
|
end
|
||||||
|
|
||||||
# An HTTP parse error has occured.
|
# An HTTP parse error has occured.
|
||||||
# +server+ is the Server object, +env+ the request, and +error+ a
|
# +server+ is the Server object, +env+ the request, and +error+ a
|
||||||
# parsing exception.
|
# parsing exception.
|
||||||
|
@ -113,18 +130,4 @@ module Puma
|
||||||
Events.new $stdout, $stderr
|
Events.new $stdout, $stderr
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue