Module: AppProfiler::Server

Defined in:
lib/app_profiler/server.rb

Constant Summary collapse

HTTP_OK =
200
HTTP_BAD_REQUEST =
400
HTTP_NOT_FOUND =
404
HTTP_NOT_ALLOWED =
405
HTTP_CONFLICT =
409
TRANSPORT_UNIX =
"unix"
TRANSPORT_TCP =
"tcp"
DEFAULTS =
{
  enabled: false,
  transport: TRANSPORT_UNIX,
  cors: true,
  cors_host: "*",
  port: 0,
  duration: 30,
}

Class Method Summary collapse

Class Method Details

.clientObject



335
336
337
338
339
# File 'lib/app_profiler/server.rb', line 335

def client
  return unless profile_server

  profile_server.client
end

.resetObject



319
320
321
322
323
324
325
# File 'lib/app_profiler/server.rb', line 319

def reset
  profile_servers.clear

  DEFAULTS.each do |config, value|
    class_variable_set(:"@@#{config}", value) # rubocop:disable Style/ClassVars
  end
end

.start(logger = Logger.new(IO::NULL)) ⇒ Object



327
328
329
330
331
332
333
# File 'lib/app_profiler/server.rb', line 327

def start(logger = Logger.new(IO::NULL))
  return if profile_server

  profile_servers[Process.pid] = ProfileServer.new(AppProfiler::Server.transport, logger)
  profile_server.serve
  profile_server
end

.stopObject



341
342
343
344
345
346
# File 'lib/app_profiler/server.rb', line 341

def stop
  return unless profile_server

  profile_server.stop
  profile_servers.delete(Process.pid)
end