Class: AppProfiler::Server::ProfileServer::TCP
- Defined in:
- lib/app_profiler/server.rb
Constant Summary collapse
- SERVER_ADDRESS =
it is ONLY safe to run this bound to localhost
"127.0.0.1"
Instance Attribute Summary
Attributes inherited from Transport
Instance Method Summary collapse
- #abandon ⇒ Object
- #client ⇒ Object
-
#initialize(port = 0) ⇒ TCP
constructor
A new instance of TCP.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(port = 0) ⇒ TCP
Returns a new instance of TCP.
240 241 242 243 |
# File 'lib/app_profiler/server.rb', line 240 def initialize(port = 0) @port_argument = port super() end |
Instance Method Details
#abandon ⇒ Object
261 262 263 264 |
# File 'lib/app_profiler/server.rb', line 261 def abandon @port_file.close # NB: Tempfile finalizer checks Process.pid to avoid unlinking inherited IOs. @socket.close end |
#client ⇒ Object
252 253 254 |
# File 'lib/app_profiler/server.rb', line 252 def client TCPSocket.new(SERVER_ADDRESS, @port) end |
#start ⇒ Object
245 246 247 248 249 250 |
# File 'lib/app_profiler/server.rb', line 245 def start FileUtils.mkdir_p(PROFILER_TEMPFILE_PATH) @socket = TCPServer.new(SERVER_ADDRESS, @port_argument) @port = @socket.addr[1] @port_file = Tempfile.new("profileserver-#{Process.pid}-port-#{@port}-", PROFILER_TEMPFILE_PATH) end |
#stop ⇒ Object
256 257 258 259 |
# File 'lib/app_profiler/server.rb', line 256 def stop @port_file.unlink @socket.close end |