Class: AppProfiler::Server::ProfileServer::UNIX

Inherits:
Transport
  • Object
show all
Defined in:
lib/app_profiler/server.rb

Instance Attribute Summary

Attributes inherited from Transport

#socket

Instance Method Summary collapse

Constructor Details

#initializeUNIX

Returns a new instance of UNIX.



193
194
195
196
197
198
199
200
# File 'lib/app_profiler/server.rb', line 193

def initialize
  super

  FileUtils.mkdir_p(PROFILER_TEMPFILE_PATH)
  @socket_file = File.join(PROFILER_TEMPFILE_PATH, "app-profiler-#{Process.pid}.sock")
  File.unlink(@socket_file) if File.exist?(@socket_file) && File.socket?(@socket_file)
  @socket = UNIXServer.new(@socket_file)
end

Instance Method Details

#clientObject



202
203
204
# File 'lib/app_profiler/server.rb', line 202

def client
  UNIXSocket.new(@socket_file)
end

#stopObject



206
207
208
209
# File 'lib/app_profiler/server.rb', line 206

def stop
  File.unlink(@socket_file) if File.exist?(@socket_file) && File.socket?(@socket_file)
  @socket.close
end