Class: Thin::Backends::AttachSocket
- Inherits:
-
Base
- Object
- Base
- Thin::Backends::AttachSocket
- Defined in:
- lib/thin/attach_socket.rb
Overview
Backend to act as a TCP server using an already opened file descriptor. Currently requires a patched EventMachine like github.com/ibc/EventMachine-LE
If you’re running thin inside a reactor with other servers, then pass preserve_reactor: true. This ensures that when you stop the Thin server, it will not stop your reactor.
If you’re doing that you probably also want to pass signals: false so that you can control when thin shuts down:
Instance Method Summary collapse
- #connect ⇒ Object
- #disconnect ⇒ Object
-
#initialize(host, port, options) ⇒ AttachSocket
constructor
A new instance of AttachSocket.
- #stop! ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(host, port, options) ⇒ AttachSocket
Returns a new instance of AttachSocket.
39 40 41 42 43 |
# File 'lib/thin/attach_socket.rb', line 39 def initialize(host, port, ) @socket = [:socket] @preserve_reactor = !![:preserve_reactor] super() end |
Instance Method Details
#connect ⇒ Object
45 46 47 |
# File 'lib/thin/attach_socket.rb', line 45 def connect @signature = EventMachine.attach_server(@socket, Connection, &method(:initialize_connection)) end |
#disconnect ⇒ Object
49 50 51 |
# File 'lib/thin/attach_socket.rb', line 49 def disconnect EventMachine.stop_server(@signature) end |
#stop! ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/thin/attach_socket.rb', line 57 def stop! if @preserve_reactor # This is the code for super, with the EM::stop call removed. @running = false @stopping = false @connections.each { |connection| connection.close_connection_after_writing } close else super end end |
#to_s ⇒ Object
53 54 55 |
# File 'lib/thin/attach_socket.rb', line 53 def to_s "socket:#{@socket.inspect}" end |