The methods that are available for use inside the config file.
# File lib/puma/configuration.rb, line 160 def _load_from(path) instance_eval File.read(path), path, 1 end
Start the Puma control rack app on url. This app can be communicated with to control the main server.
# File lib/puma/configuration.rb, line 178 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
Use obj or block as the Rack app. This allows a config file to be the app itself.
# File lib/puma/configuration.rb, line 167 def app(obj=nil, &block) obj ||= block raise "Provide either a #call'able or a block" unless obj @options[:app] = obj end
Bind the server to url. tcp:// and unix:// are the only accepted protocols.
# File lib/puma/configuration.rb, line 195 def bind(url) @options[:binds] << url end
Daemonize the server into the background. Highly suggest that this be combined with pidfile and stdout_redirect.
# File lib/puma/configuration.rb, line 207 def daemonize(which=true) @options[:daemon] = which end
The directory to operate out of.
# File lib/puma/configuration.rb, line 311 def directory(dir) @options[:directory] = dir.to_s @options[:worker_directory] = dir.to_s end
When shutting down, drain the accept socket of pending connections and proces them. This loops over the accept socket until there are no more read events and then stops looking and waits for the requests to finish.
# File lib/puma/configuration.rb, line 215 def drain_on_shutdown(which=true) @options[:drain_on_shutdown] = which end
Set the environment in which the Rack's app will run.
# File lib/puma/configuration.rb, line 220 def environment(environment) @options[:environment] = environment end
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.
# File lib/puma/configuration.rb, line 229 def on_restart(&block) @options[:on_restart] << block end
*Cluster mode only* Code to run when a worker boots to setup the process before booting the app.
This can be called multiple times to add hooks.
# File lib/puma/configuration.rb, line 306 def on_worker_boot(&block) @options[:worker_boot] << block end
Store the pid of the server in the file at path.
# File lib/puma/configuration.rb, line 242 def pidfile(path) @options[:pidfile] = path end
Define the TCP port to bind to. Use bind for more advanced options.
# File lib/puma/configuration.rb, line 201 def port(port) @options[:binds] << "tcp://#{Configuration::DefaultTCPHost}:#{port}" end
*Cluster mode only* Preload the application before starting the workers and setting up the listen ports. This conflicts with using the phased restart feature, you can't use both.
# File lib/puma/configuration.rb, line 325 def preload_app!(answer=true) @options[:preload_app] = answer end
Disable request logging.
# File lib/puma/configuration.rb, line 248 def quiet @options[:quiet] = true end
Load path as a rackup file.
# File lib/puma/configuration.rb, line 254 def rackup(path) @options[:rackup] = path.to_s end
Command to use to restart puma. This should be just how to load puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments to puma, as those are the same as the original process.
# File lib/puma/configuration.rb, line 237 def restart_command(cmd) @options[:restart_cmd] = cmd end
# File lib/puma/configuration.rb, line 279 def ssl_bind(host, port, opts) o = [ "cert=#{opts[:cert]}", "key=#{opts[:key]}" ] @options[:binds] << "ssl://#{host}:#{port}?#{o.join('&')}" end
Use path as the file to store the server info state. This is used by pumactl to query and control the server.
# File lib/puma/configuration.rb, line 291 def state_path(path) @options[:state] = path.to_s end
Redirect STDOUT and STDERR to files specified.
# File lib/puma/configuration.rb, line 259 def stdout_redirect(stdout=nil, stderr=nil, append=false) @options[:redirect_stdout] = stdout @options[:redirect_stderr] = stderr @options[:redirect_append] = append end
Run the app as a raw TCP app instead of an HTTP rack app
# File lib/puma/configuration.rb, line 317 def tcp_mode @options[:mode] = :tcp end
Configure min to be the minimum number of threads to use to answer requests and max the maximum.
# File lib/puma/configuration.rb, line 268 def threads(min, max) min = Integer(min) max = Integer(max) if min > max raise "The minimum (#{min}) number of threads must be less than the max (#{max})" end @options[:min_threads] = min @options[:max_threads] = max end
*Cluster mode only* How many worker processes to run.
# File lib/puma/configuration.rb, line 297 def workers(count) @options[:workers] = count.to_i end
Generated with the Darkfish Rdoc Generator 2.