class Plum::Rack::UNIXListener
Public Class Methods
new(lc)
click to toggle source
# File lib/plum/rack/listener.rb, line 139 def initialize(lc) if File.exist?(lc[:path]) begin old = UNIXSocket.new(lc[:path]) rescue SystemCallError, IOError File.unlink(lc[:path]) else old.close raise "Already a server bound to: #{lc[:path]}" end end @server = ::UNIXServer.new(lc[:path]) File.chmod(lc[:mode], lc[:path]) if lc[:mode] end
Public Instance Methods
accept(svc)
click to toggle source
# File lib/plum/rack/listener.rb, line 165 def accept(svc) sock = @server.accept Thread.start { begin plum = ::Plum::ServerConnection.new(sock.method(:write)) sess = Session.new(svc, sock, plum) sess.run rescue Errno::ECONNRESET, EOFError # closed rescue => e svc.log_exception(e) ensure sock.close if sock end } end
stop()
click to toggle source
Calls superclass method
Plum::Rack::BaseListener#stop
# File lib/plum/rack/listener.rb, line 156 def stop super File.unlink(lc[:path]) end
to_io()
click to toggle source
# File lib/plum/rack/listener.rb, line 161 def to_io @server.to_io end