Class: Puma::Configuration::DSL
- Inherits:
-
Object
- Object
- Puma::Configuration::DSL
- Defined in:
- lib/puma/configuration.rb
Overview
The methods that are available for use inside the config file.
Instance Method Summary collapse
- #_load_from(path) ⇒ Object
-
#activate_control_app(url = "auto", opts = nil) ⇒ Object
Start the Puma control rack app on
url
. -
#app(obj = nil, &block) ⇒ Object
Use
obj
orblock
as the Rack app. -
#bind(url) ⇒ Object
Bind the server to
url
. -
#initialize(options) ⇒ DSL
constructor
A new instance of DSL.
-
#on_restart(&blk) ⇒ Object
Code to run before doing a restart.
-
#pidfile(path) ⇒ Object
Store the pid of the server in the file at
path
. -
#quiet ⇒ Object
Disable request logging.
-
#rackup(path) ⇒ Object
Load
path
as a rackup file. - #ssl_bind(host, port, opts) ⇒ Object
-
#state_path(path) ⇒ Object
Use
path
as the file to store the server info state. -
#threads(min, max) ⇒ Object
Configure
min
to be the minimum number of threads to use to answer requests andmax
the maximum.
Constructor Details
#initialize(options) ⇒ DSL
Returns a new instance of DSL.
115 116 117 |
# File 'lib/puma/configuration.rb', line 115 def initialize() @options = end |
Instance Method Details
#_load_from(path) ⇒ Object
119 120 121 |
# File 'lib/puma/configuration.rb', line 119 def _load_from(path) instance_eval File.read(path), path, 1 end |
#activate_control_app(url = "auto", opts = nil) ⇒ Object
Start the Puma control rack app on url
. This app can be communicated with to control the main server.
137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/puma/configuration.rb', line 137 def activate_control_app(url="auto", opts=nil) @options[:control_url] = url if opts if tok = opts[:auth_token] @options[:control_auth_token] = tok end if opts[:no_token] @options[:control_auth_token] = :none end end end |
#app(obj = nil, &block) ⇒ Object
Use obj
or block
as the Rack app. This allows a config file to be the app itself.
126 127 128 129 130 131 132 |
# File 'lib/puma/configuration.rb', line 126 def app(obj=nil, &block) obj ||= block raise "Provide either a #call'able or a block" unless obj @options[:app] = obj end |
#bind(url) ⇒ Object
Bind the server to url
. tcp:// and unix:// are the only accepted protocols.
154 155 156 |
# File 'lib/puma/configuration.rb', line 154 def bind(url) @options[:binds] << url end |
#on_restart(&blk) ⇒ Object
Code to run before doing a restart. This code should close logfiles, database connections, etc.
This can be called multiple times to add code each time.
163 164 165 |
# File 'lib/puma/configuration.rb', line 163 def on_restart(&blk) @options[:on_restart] << blk end |
#pidfile(path) ⇒ Object
Store the pid of the server in the file at path
.
168 169 170 |
# File 'lib/puma/configuration.rb', line 168 def pidfile(path) @options[:pidfile] = path end |
#quiet ⇒ Object
Disable request logging.
174 175 176 |
# File 'lib/puma/configuration.rb', line 174 def quiet @options[:quiet] = true end |
#rackup(path) ⇒ Object
Load path
as a rackup file.
180 181 182 |
# File 'lib/puma/configuration.rb', line 180 def rackup(path) @options[:rackup] = path.to_s end |
#ssl_bind(host, port, opts) ⇒ Object
196 197 198 199 200 201 202 203 |
# File 'lib/puma/configuration.rb', line 196 def ssl_bind(host, port, opts) o = [ "cert=#{opts[:cert]}", "key=#{opts[:key]}" ] @options[:binds] << "ssl://#{host}:#{port}?#{o.join('&')}" end |
#state_path(path) ⇒ Object
Use path
as the file to store the server info state. This is used by pumactl to query and control the server.
208 209 210 |
# File 'lib/puma/configuration.rb', line 208 def state_path(path) @options[:state] = path.to_s end |
#threads(min, max) ⇒ Object
Configure min
to be the minimum number of threads to use to answer requests and max
the maximum.
187 188 189 190 191 192 193 194 |
# File 'lib/puma/configuration.rb', line 187 def threads(min, max) if min > max raise "The minimum number of threads must be less than the max" end @options[:min_threads] = min @options[:max_threads] = max end |