diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index eb9a1d2c..7c68eebe 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -120,7 +120,7 @@ module Puma umask = nil mode = nil - backlog = nil + backlog = 1024 if uri.query params = Util.parse_query uri.query @@ -344,7 +344,7 @@ module Puma # Tell the server to listen on +path+ as a UNIX domain socket. # - def add_unix_listener(path, umask=nil, mode=nil, backlog=nil) + def add_unix_listener(path, umask=nil, mode=nil, backlog=1024) @unix_paths << path # Let anyone connect by default @@ -365,7 +365,7 @@ module Puma end s = UNIXServer.new(path) - s.listen backlog if backlog + s.listen backlog @ios << s ensure File.umask old_mask diff --git a/lib/puma/dsl.rb b/lib/puma/dsl.rb index 0773f6fb..64da03aa 100644 --- a/lib/puma/dsl.rb +++ b/lib/puma/dsl.rb @@ -110,9 +110,22 @@ module Puma @options[:config_files] << file end - # Bind the server to +url+. tcp:// and unix:// are the only accepted - # protocols. + # Adds a binding for the server to +url+. tcp://, unix://, and ssl:// are the only accepted + # protocols. Use query parameters within the url to specify options. # + # @note multiple urls can be bound to, calling `bind` does not overwrite previous bindings. + # + # @example Explicitly the socket backlog depth (default is 1024) + # bind('unix:///var/run/puma.sock?backlog=2048') + # + # @example Set up ssl cert + # bind('ssl://127.0.0.1:9292?key=key.key&cert=cert.pem') + # + # @example Prefer low-latency over higher throughput (via `Socket::TCP_NODELAY`) + # bind('tcp://0.0.0.0:9292?low_latency=true') + # + # @example Set socket permissions + # bind('unix:///var/run/puma.sock?umask=0111') def bind(url) @options[:binds] ||= [] @options[:binds] << url