2013-03-01 08:45:29 -05:00
|
|
|
#!/usr/bin/env puma
|
2011-12-06 17:56:38 -05:00
|
|
|
|
2013-03-01 08:45:29 -05:00
|
|
|
# The directory to operate out of.
|
|
|
|
#
|
2013-03-01 09:51:46 -05:00
|
|
|
# The default is the current directory.
|
|
|
|
#
|
2013-03-01 08:45:29 -05:00
|
|
|
# directory '/u/apps/lolcat'
|
|
|
|
|
2013-10-21 13:16:23 -04:00
|
|
|
# Use an object or block as the rack application. This allows the
|
2013-03-01 08:45:29 -05:00
|
|
|
# config file to be the application itself.
|
|
|
|
#
|
|
|
|
# app do |env|
|
|
|
|
# puts env
|
|
|
|
#
|
|
|
|
# body = 'Hello, World!'
|
|
|
|
#
|
|
|
|
# [200, { 'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
|
|
|
|
# end
|
|
|
|
|
2015-01-31 23:11:39 -05:00
|
|
|
# Load "path" as a rackup file.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
2015-01-31 23:11:39 -05:00
|
|
|
# The default is "config.ru".
|
2013-03-01 09:51:46 -05:00
|
|
|
#
|
|
|
|
# rackup '/u/apps/lolcat/config.ru'
|
2013-03-01 08:45:29 -05:00
|
|
|
|
2013-05-03 02:42:13 -04:00
|
|
|
# Set the environment in which the rack's app will run. The value must be a string.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
2015-01-31 23:11:39 -05:00
|
|
|
# The default is "development".
|
2013-03-01 09:51:46 -05:00
|
|
|
#
|
2013-05-03 02:42:13 -04:00
|
|
|
# environment 'production'
|
2013-03-01 08:45:29 -05:00
|
|
|
|
|
|
|
# Daemonize the server into the background. Highly suggest that
|
2015-01-31 23:11:39 -05:00
|
|
|
# this be combined with "pidfile" and "stdout_redirect".
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
2015-01-31 23:11:39 -05:00
|
|
|
# The default is "false".
|
2013-03-01 09:51:46 -05:00
|
|
|
#
|
2013-03-01 08:45:29 -05:00
|
|
|
# daemonize
|
|
|
|
# daemonize false
|
|
|
|
|
2015-01-31 23:11:39 -05:00
|
|
|
# Store the pid of the server in the file at "path".
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
|
|
|
# pidfile '/u/apps/lolcat/tmp/pids/puma.pid'
|
|
|
|
|
2015-01-31 23:11:39 -05:00
|
|
|
# Use "path" as the file to store the server info state. This is
|
|
|
|
# used by "pumactl" to query and control the server.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
|
|
|
# state_path '/u/apps/lolcat/tmp/pids/puma.state'
|
|
|
|
|
2013-03-01 09:51:46 -05:00
|
|
|
# Redirect STDOUT and STDERR to files specified. The 3rd parameter
|
2015-01-31 23:11:39 -05:00
|
|
|
# ("append") specifies whether the output is appended, the default is
|
|
|
|
# "false".
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
|
|
|
# stdout_redirect '/u/apps/lolcat/log/stdout', '/u/apps/lolcat/log/stderr'
|
|
|
|
# stdout_redirect '/u/apps/lolcat/log/stdout', '/u/apps/lolcat/log/stderr', true
|
|
|
|
|
|
|
|
# Disable request logging.
|
|
|
|
#
|
2015-01-31 23:11:39 -05:00
|
|
|
# The default is "false".
|
2013-03-01 09:51:46 -05:00
|
|
|
#
|
2013-03-01 08:45:29 -05:00
|
|
|
# quiet
|
|
|
|
|
2015-01-31 23:11:39 -05:00
|
|
|
# Configure "min" to be the minimum number of threads to use to answer
|
|
|
|
# requests and "max" the maximum.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
2015-01-31 23:11:39 -05:00
|
|
|
# The default is "0, 16".
|
2013-03-01 09:51:46 -05:00
|
|
|
#
|
2013-03-01 08:45:29 -05:00
|
|
|
# threads 0, 16
|
|
|
|
|
2015-01-31 23:11:39 -05:00
|
|
|
# Bind the server to "url". "tcp://", "unix://" and "ssl://" are the only
|
2013-03-01 08:45:29 -05:00
|
|
|
# accepted protocols.
|
|
|
|
#
|
2015-01-31 23:11:39 -05:00
|
|
|
# The default is "tcp://0.0.0.0:9292".
|
2013-03-01 09:51:46 -05:00
|
|
|
#
|
2013-03-01 08:45:29 -05:00
|
|
|
# bind 'tcp://0.0.0.0:9292'
|
|
|
|
# bind 'unix:///var/run/puma.sock'
|
2014-11-14 13:39:28 -05:00
|
|
|
# bind 'unix:///var/run/puma.sock?umask=0111'
|
2013-03-01 08:45:29 -05:00
|
|
|
# bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
|
|
|
|
|
2015-01-31 23:11:39 -05:00
|
|
|
# Instead of "bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'" you
|
|
|
|
# can also use the "ssl_bind" option.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
2015-12-01 11:35:23 -05:00
|
|
|
# ssl_bind '127.0.0.1', '9292', {
|
|
|
|
# key: path_to_key,
|
|
|
|
# cert: path_to_cert
|
|
|
|
# }
|
|
|
|
# for JRuby additional keys are required:
|
|
|
|
# keystore: path_to_keystore,
|
|
|
|
# keystore_pass: password
|
2013-03-01 08:45:29 -05:00
|
|
|
|
|
|
|
# Code to run before doing a restart. This code should
|
2013-03-01 09:56:35 -05:00
|
|
|
# close log files, database connections, etc.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
|
|
|
# This can be called multiple times to add code each time.
|
|
|
|
#
|
|
|
|
# on_restart do
|
|
|
|
# puts 'On restart...'
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# restart_command '/u/app/lolcat/bin/restart_puma'
|
|
|
|
|
|
|
|
# === Cluster mode ===
|
|
|
|
|
2016-09-23 11:47:24 -04:00
|
|
|
# How many worker processes to run. Typically this is set to
|
|
|
|
# to the number of available cores.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
2015-01-31 23:11:39 -05:00
|
|
|
# The default is "0".
|
2013-03-01 09:51:46 -05:00
|
|
|
#
|
2013-03-01 08:45:29 -05:00
|
|
|
# workers 2
|
|
|
|
|
2016-04-11 06:29:32 -04:00
|
|
|
# Code to run immediately before the master starts workers.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
2016-04-07 16:50:08 -04:00
|
|
|
# before_fork do
|
|
|
|
# puts "Starting workers..."
|
|
|
|
# end
|
|
|
|
|
|
|
|
# Code to run in a worker before it starts serving requests.
|
|
|
|
#
|
|
|
|
# This is called everytime a worker is to be started.
|
2013-03-01 08:45:29 -05:00
|
|
|
#
|
|
|
|
# on_worker_boot do
|
|
|
|
# puts 'On worker boot...'
|
|
|
|
# end
|
|
|
|
|
2016-04-07 16:50:08 -04:00
|
|
|
# Code to run in a worker right before it exits.
|
2014-02-26 09:06:58 -05:00
|
|
|
#
|
2016-04-11 06:29:32 -04:00
|
|
|
# This is called everytime a worker is to about to shutdown.
|
2014-02-26 09:06:58 -05:00
|
|
|
#
|
2016-04-07 16:50:08 -04:00
|
|
|
# on_worker_shutdown do
|
|
|
|
# puts 'On worker shutdown...'
|
2014-02-26 09:06:58 -05:00
|
|
|
# end
|
|
|
|
|
2016-04-07 16:50:08 -04:00
|
|
|
# Code to run in the master right before a worker is started. The worker's
|
|
|
|
# index is passed as an argument.
|
2015-01-13 03:44:14 -05:00
|
|
|
#
|
2016-04-07 16:50:08 -04:00
|
|
|
# This is called everytime a worker is to be started.
|
2015-01-13 03:44:14 -05:00
|
|
|
#
|
2016-04-07 16:50:08 -04:00
|
|
|
# on_worker_fork do
|
|
|
|
# puts 'Before worker fork...'
|
|
|
|
# end
|
|
|
|
|
|
|
|
# Code to run in the master after a worker has been started. The worker's
|
2016-05-17 10:31:15 -04:00
|
|
|
# index is passed as an argument.
|
2016-04-07 16:50:08 -04:00
|
|
|
#
|
|
|
|
# This is called everytime a worker is to be started.
|
|
|
|
#
|
|
|
|
# after_worker_fork do
|
|
|
|
# puts 'After worker fork...'
|
2015-01-13 03:44:14 -05:00
|
|
|
# end
|
|
|
|
|
2014-03-01 18:47:12 -05:00
|
|
|
# Allow workers to reload bundler context when master process is issued
|
2014-03-01 19:03:40 -05:00
|
|
|
# a USR1 signal. This allows proper reloading of gems while the master
|
|
|
|
# is preserved across a phased-restart. (incompatible with preload_app)
|
2014-03-06 17:16:28 -05:00
|
|
|
# (off by default)
|
2014-03-01 18:47:12 -05:00
|
|
|
|
|
|
|
# prune_bundler
|
|
|
|
|
|
|
|
# Preload the application before starting the workers; this conflicts with
|
2014-03-06 17:16:28 -05:00
|
|
|
# phased restart feature. (off by default)
|
2014-03-01 18:47:12 -05:00
|
|
|
|
2014-04-02 14:45:55 -04:00
|
|
|
# preload_app!
|
2014-03-01 18:47:12 -05:00
|
|
|
|
2014-03-07 02:06:38 -05:00
|
|
|
# Additional text to display in process listing
|
|
|
|
#
|
|
|
|
# tag 'app name'
|
2015-10-01 11:41:28 -04:00
|
|
|
#
|
|
|
|
# If you do not specify a tag, Puma will infer it. If you do not want Puma
|
|
|
|
# to add a tag, use an empty string.
|
2014-03-07 02:06:38 -05:00
|
|
|
|
2015-11-03 10:33:49 -05:00
|
|
|
# Verifies that all workers have checked in to the master process within
|
2016-11-20 13:38:36 -05:00
|
|
|
# the given timeout. If not the worker process will be restarted. This is
|
|
|
|
# not a request timeout, it is to protect against a hung or dead process.
|
|
|
|
# Setting this value will not protect against slow requests.
|
|
|
|
# Default value is 60 seconds.
|
2014-03-26 07:37:06 -04:00
|
|
|
#
|
|
|
|
# worker_timeout 60
|
2014-03-01 18:47:12 -05:00
|
|
|
|
2015-11-06 11:46:48 -05:00
|
|
|
# Change the default worker timeout for booting
|
|
|
|
#
|
|
|
|
# If unspecified, this defaults to the value of worker_timeout.
|
|
|
|
#
|
|
|
|
# worker_boot_timeout 60
|
|
|
|
|
2013-03-01 08:45:29 -05:00
|
|
|
# === Puma control rack application ===
|
|
|
|
|
2015-01-31 23:11:39 -05:00
|
|
|
# Start the puma control rack application on "url". This application can
|
2013-03-01 08:45:29 -05:00
|
|
|
# be communicated with to control the main server. Additionally, you can
|
|
|
|
# provide an authentication token, so all requests to the control server
|
|
|
|
# will need to include that token as a query parameter. This allows for
|
|
|
|
# simple authentication.
|
|
|
|
#
|
|
|
|
# Check out https://github.com/puma/puma/blob/master/lib/puma/app/status.rb
|
|
|
|
# to see what the app has available.
|
|
|
|
#
|
|
|
|
# activate_control_app 'unix:///var/run/pumactl.sock'
|
|
|
|
# activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345' }
|
2013-05-03 02:42:13 -04:00
|
|
|
# activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true }
|