Class: AppProfiler::Server::ProfileServer::UNIX
Instance Attribute Summary
Attributes inherited from Transport
#socket
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Transport
#initialize
Class Method Details
.unlink_socket(path, pid) ⇒ Object
202
203
204
205
206
207
208
209
210
211
212
|
# File 'lib/app_profiler/server.rb', line 202
def unlink_socket(path, pid)
->(_) do
if Process.pid == pid && File.exist?(path)
begin
File.unlink(path)
rescue SystemCallError
end
end
end
end
|
Instance Method Details
#abandon ⇒ Object
234
235
236
|
# File 'lib/app_profiler/server.rb', line 234
def abandon
@socket.close
end
|
#client ⇒ Object
223
224
225
|
# File 'lib/app_profiler/server.rb', line 223
def client
UNIXSocket.new(@socket_file)
end
|
#start ⇒ Object
215
216
217
218
219
220
221
|
# File 'lib/app_profiler/server.rb', line 215
def start
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)
ObjectSpace.define_finalizer(self, self.class.unlink_socket(@socket_file, Process.pid))
end
|
#stop ⇒ Object
227
228
229
230
231
232
|
# File 'lib/app_profiler/server.rb', line 227
def stop
@socket.close
File.unlink(@socket_file) if File.exist?(@socket_file) && File.socket?(@socket_file)
ObjectSpace.undefine_finalizer(self)
nil
end
|