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.



148
149
150
151
152
153
154
# File 'lib/app_profiler/server.rb', line 148

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



156
157
158
# File 'lib/app_profiler/server.rb', line 156

def client
  UNIXSocket.new(@socket_file)
end

#stopObject



160
161
162
163
# File 'lib/app_profiler/server.rb', line 160

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