Sha256: bcfc338838e63452ba795f23c5357055c895c32eab80f44a1a0a893f861005c6

Contents?: true

Size: 1.02 KB

Versions: 3

Compression:

Stored size: 1.02 KB

Contents

require 'instrumentation/version'
require 'pathname'
require 'json'
require 'rack'
require 'puma'
require 'erb/view'

Erb.root = Pathname.new(__FILE__).join('..', '..').join('lib/templates')

# Instrumentation
#
# Start a server by calling:
#   Instrumentation.start_server(Process.pid)
#
# By default the server is started on http://localhost:8080
module Instrumentation
  def start_server(pid:, port: 8080)
    report = Report.new(pid)
    app = RackApp.new(report)
    server = Webserver.new

    report.start
    server.run(app, port: port)

    [server, report].map(&:join)
  rescue Interrupt => _
    print "\n=> Shutting down instrumentation.\n"
    report.shutdown
    server.stop
  end

  def root
    Pathname.new(__FILE__).join('..', '..')
  end

  module_function :start_server, :root
end

require 'instrumentation/bounded_array'
require 'instrumentation/memory'
require 'instrumentation/load_average'
require 'instrumentation/rack_app'
require 'instrumentation/report'
require 'instrumentation/view'
require 'instrumentation/webserver'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
process-instrumentation-0.1.3 lib/instrumentation.rb
process-instrumentation-0.1.2 lib/instrumentation.rb
process-instrumentation-0.1.1 lib/instrumentation.rb