Class: Instrumentation::Webserver

Inherits:
Object
  • Object
show all
Defined in:
lib/instrumentation/webserver.rb

Overview

Webserver using ‘puma` that handles requests for stats

Instance Method Summary collapse

Constructor Details

#initializeWebserver

Returns a new instance of Webserver.



4
5
6
# File 'lib/instrumentation/webserver.rb', line 4

def initialize
  @worker = nil
end

Instance Method Details

#joinObject



15
16
17
# File 'lib/instrumentation/webserver.rb', line 15

def join
  @worker.join
end

#run(app, opts = {}) ⇒ Object



8
9
10
11
12
13
# 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

#stopObject



19
20
21
22
# File 'lib/instrumentation/webserver.rb', line 19

def stop
  @launcher.stop
  @worker.kill
end