mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
095964879b
* Revert api change from #2086 introduce Puma.stats_hash api The change in #2086 is not backwards compatible with existing gems that parse the output of Puma.stats such as barnes. Releasing a version of puma with this change would break anyone using the Barnes app and only in production. I'm proposing to keep the existing interface and instead add a new API. This buys us all the features of #2086 without causing any production facing downtime by customers due to API incompatibilities. Unfortunately it requires that we serialize and the de-serialize the values. One prior benefit of returning json in a string was that it allowed an end user to de-serialize using a faster json algorithm such as `oj` via the "multi json" gem. But the performance penalty will be better than a stability break.
35 lines
619 B
Ruby
35 lines
619 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Standard libraries
|
|
require 'socket'
|
|
require 'tempfile'
|
|
require 'time'
|
|
require 'etc'
|
|
require 'uri'
|
|
require 'stringio'
|
|
|
|
require 'thread'
|
|
|
|
module Puma
|
|
autoload :Const, 'puma/const'
|
|
autoload :Server, 'puma/server'
|
|
autoload :Launcher, 'puma/launcher'
|
|
|
|
def self.stats_object=(val)
|
|
@get_stats = val
|
|
end
|
|
|
|
def self.stats
|
|
@get_stats.stats.to_json
|
|
end
|
|
|
|
def self.stats_hash
|
|
@get_stats.stats
|
|
end
|
|
|
|
# Thread name is new in Ruby 2.3
|
|
def self.set_thread_name(name)
|
|
return unless Thread.current.respond_to?(:name=)
|
|
Thread.current.name = "puma #{name}"
|
|
end
|
|
end
|