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



281
282
283
284
285
# File 'lib/app_profiler/server.rb', line 281

def client
  return unless profile_server

  profile_server.client
end

.resetObject



266
267
268
269
270
271
# File 'lib/app_profiler/server.rb', line 266

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

.startObject



273
274
275
276
277
278
279
# File 'lib/app_profiler/server.rb', line 273

def start
  return if profile_server

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

.stopObject



287
288
289
290
291
292
# File 'lib/app_profiler/server.rb', line 287

def stop
  return unless profile_server

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