class Instrumentation::Webserver
Webserver
using `puma` that handles requests for stats
Public Class Methods
new()
click to toggle source
# File lib/instrumentation/webserver.rb, line 4 def initialize @worker = nil end
Public Instance Methods
join()
click to toggle source
# File lib/instrumentation/webserver.rb, line 15 def join @worker.join end
run(app, opts = {})
click to toggle source
# File lib/instrumentation/webserver.rb, line 8 def run(app, opts = {}) config = build_config(opts.merge(app: app)) @launcher = Puma::Launcher.new(config, events: Puma::Events.stdio) @worker = Thread.new { @launcher.run } end
stop()
click to toggle source
# File lib/instrumentation/webserver.rb, line 19 def stop @launcher.stop @worker.kill end
Private Instance Methods
build_config(opts)
click to toggle source
# File lib/instrumentation/webserver.rb, line 26 def build_config(opts) Puma::Configuration.new do |c| host = opts.fetch(:host, Puma::Configuration::DefaultTCPHost) port = opts.fetch(:port, Puma::Configuration::DefaultTCPPort) c.port port, host c.app opts.fetch(:app) end end