Class: Thin::Backends::UnixServer
- Defined in:
- lib/thin/backends/unix_server.rb
Overview
Backend to act as a UNIX domain socket server.
Instance Attribute Summary collapse
-
#socket ⇒ Object
UNIX domain socket on which the server is listening for connections.
Attributes inherited from Base
#maximum_connections, #maximum_persistent_connections, #no_epoll, #persistent_connection_count, #server, #ssl, #ssl_options, #threaded, #timeout
Instance Method Summary collapse
-
#close ⇒ Object
Free up resources used by the backend.
-
#connect ⇒ Object
Connect the server.
-
#disconnect ⇒ Object
Stops the server.
-
#initialize(socket) ⇒ UnixServer
constructor
A new instance of UnixServer.
- #to_s ⇒ Object
Methods inherited from Base
#config, #connection_finished, #empty?, #running?, #size, #ssl?, #start, #stop, #stop!, #threaded?
Constructor Details
#initialize(socket) ⇒ UnixServer
Returns a new instance of UnixServer.
8 9 10 11 12 |
# File 'lib/thin/backends/unix_server.rb', line 8 def initialize(socket) raise PlatformNotSupported, 'UNIX domain sockets not available on Windows' if Thin.win? @socket = socket super() end |
Instance Attribute Details
#socket ⇒ Object
UNIX domain socket on which the server is listening for connections.
6 7 8 |
# File 'lib/thin/backends/unix_server.rb', line 6 def socket @socket end |
Instance Method Details
#close ⇒ Object
Free up resources used by the backend.
29 30 31 |
# File 'lib/thin/backends/unix_server.rb', line 29 def close remove_socket_file end |
#connect ⇒ Object
Connect the server
15 16 17 18 19 20 21 |
# File 'lib/thin/backends/unix_server.rb', line 15 def connect at_exit { remove_socket_file } # In case it crashes EventMachine.start_unix_domain_server(@socket, UnixConnection, &method(:initialize_connection)) # HACK EventMachine.start_unix_domain_server doesn't return the connection signature # so we have to go in the internal stuff to find it. @signature = EventMachine.instance_eval{@acceptors.keys.first} end |
#disconnect ⇒ Object
Stops the server
24 25 26 |
# File 'lib/thin/backends/unix_server.rb', line 24 def disconnect EventMachine.stop_server(@signature) end |
#to_s ⇒ Object
33 34 35 |
# File 'lib/thin/backends/unix_server.rb', line 33 def to_s @socket end |