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.
242 243 244 245 |
# File 'lib/app_profiler/server.rb', line 242 def initialize(port = 0) @port_argument = port super() end |
Instance Method Details
#abandon ⇒ Object
263 264 265 266 |
# File 'lib/app_profiler/server.rb', line 263 def abandon @port_file.close # NB: Tempfile finalizer checks Process.pid to avoid unlinking inherited IOs. @socket.close end |
#client ⇒ Object
254 255 256 |
# File 'lib/app_profiler/server.rb', line 254 def client TCPSocket.new(SERVER_ADDRESS, @port) end |
#start ⇒ Object
247 248 249 250 251 252 |
# File 'lib/app_profiler/server.rb', line 247 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
258 259 260 261 |
# File 'lib/app_profiler/server.rb', line 258 def stop @port_file.unlink @socket.close end |