mirror of
https://github.com/puma/puma.git
synced 2022-11-09 13:48:40 -05:00
More pruning
This commit is contained in:
parent
8eb062cb09
commit
83eacd0d1c
2 changed files with 1 additions and 30 deletions
|
@ -93,23 +93,6 @@ module Puma
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generates a class for cloaking the current self and making the DSL nicer.
|
|
||||||
def cloaking_class
|
|
||||||
class << self
|
|
||||||
self
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Do not call this. You were warned.
|
|
||||||
def cloaker(&block)
|
|
||||||
cloaking_class.class_eval do
|
|
||||||
define_method :cloaker_, &block
|
|
||||||
meth = instance_method( :cloaker_ )
|
|
||||||
remove_method :cloaker_
|
|
||||||
meth
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# This will resolve the given options against the defaults.
|
# This will resolve the given options against the defaults.
|
||||||
# Normally just used internally.
|
# Normally just used internally.
|
||||||
def resolve_defaults(options)
|
def resolve_defaults(options)
|
||||||
|
@ -125,18 +108,12 @@ module Puma
|
||||||
#
|
#
|
||||||
# * :host => Host name to bind.
|
# * :host => Host name to bind.
|
||||||
# * :port => Port to bind.
|
# * :port => Port to bind.
|
||||||
# * :num_processors => The maximum number of concurrent threads allowed.
|
|
||||||
# * :throttle => Time to pause (in hundredths of a second) between accepting clients.
|
|
||||||
# * :timeout => Time to wait (in seconds) before killing a stalled thread.
|
|
||||||
# * :user => User to change to, must have :group as well.
|
# * :user => User to change to, must have :group as well.
|
||||||
# * :group => Group to change to, must have :user as well.
|
# * :group => Group to change to, must have :user as well.
|
||||||
#
|
#
|
||||||
def listener(options={})
|
def listener(options={})
|
||||||
raise "Cannot call listener inside another listener block." if (@listener or @listener_name)
|
raise "Cannot call listener inside another listener block." if (@listener or @listener_name)
|
||||||
ops = resolve_defaults(options)
|
ops = resolve_defaults(options)
|
||||||
ops[:num_processors] ||= 950
|
|
||||||
ops[:throttle] ||= 0
|
|
||||||
ops[:timeout] ||= 60
|
|
||||||
|
|
||||||
@listener = Puma::Server.new(ops[:host], ops[:port].to_i, ops[:concurrency].to_i)
|
@listener = Puma::Server.new(ops[:host], ops[:port].to_i, ops[:concurrency].to_i)
|
||||||
@listener_name = "#{ops[:host]}:#{ops[:port]}"
|
@listener_name = "#{ops[:host]}:#{ops[:port]}"
|
||||||
|
@ -146,10 +123,7 @@ module Puma
|
||||||
change_privilege(ops[:user], ops[:group])
|
change_privilege(ops[:user], ops[:group])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Does the actual cloaking operation to give the new implicit self.
|
yield self if block_given?
|
||||||
if block_given?
|
|
||||||
yield self
|
|
||||||
end
|
|
||||||
|
|
||||||
# all done processing this listener setup, reset implicit variables
|
# all done processing this listener setup, reset implicit variables
|
||||||
@listener = nil
|
@listener = nil
|
||||||
|
|
|
@ -7,11 +7,8 @@ module Puma
|
||||||
include Puma::Const
|
include Puma::Const
|
||||||
|
|
||||||
attr_reader :acceptor
|
attr_reader :acceptor
|
||||||
attr_reader :workers
|
|
||||||
attr_reader :host
|
attr_reader :host
|
||||||
attr_reader :port
|
attr_reader :port
|
||||||
attr_reader :throttle
|
|
||||||
attr_reader :timeout
|
|
||||||
attr_reader :concurrent
|
attr_reader :concurrent
|
||||||
|
|
||||||
attr_accessor :app
|
attr_accessor :app
|
||||||
|
|
Loading…
Reference in a new issue