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



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

def client
  return unless profile_server

  profile_server.client
end

.resetObject



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

def reset
  profile_servers.clear

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

.startObject



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

def start
  return if profile_server

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

.stopObject



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

def stop
  return unless profile_server

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