1+ #!/usr/bin/env puma
2+
3+ # The directory to operate out of.
4+ #
5+ # The default is the current directory.
6+ #
7+ # directory '/u/apps/lolcat'
8+
9+ # Use a object or block as the rack application. This allows the
10+ # config file to be the application itself.
11+ #
12+ # app do |env|
13+ # puts env
14+ #
15+ # body = 'Hello, World!'
16+ #
17+ # [200, { 'Content-Type' => 'text/plain', 'Content-Length' => body.length.to_s }, [body]]
18+ # end
19+
20+ # Load “path” as a rackup file.
21+ #
22+ # The default is “config.ru”.
23+ #
24+ # rackup '/u/apps/lolcat/config.ru'
25+
26+ # Set the environment in which the rack's app will run. The value must be a string.
27+ #
28+ # The default is “development”.
29+ #
30+ environment 'production'
31+
32+ # Daemonize the server into the background. Highly suggest that
33+ # this be combined with “pidfile” and “stdout_redirect”.
34+ #
35+ # The default is “false”.
36+ #
37+ # daemonize
38+ daemonize true
39+
40+ wd = File . expand_path ( '../../' , __FILE__ )
41+ tmp_path = File . join ( wd , 'log' )
42+ Dir . mkdir ( tmp_path ) unless File . exist? ( tmp_path )
43+
44+ pidfile File . join ( tmp_path , 'puma.pid' )
45+ state_path File . join ( tmp_path , 'puma.state' )
46+ stdout_redirect File . join ( tmp_path , 'puma.out.log' ) , File . join ( tmp_path , 'puma.err.log' ) , true
47+
48+ # Store the pid of the server in the file at “path”.
49+ #
50+ # pidfile '/u/apps/lolcat/tmp/pids/puma.pid'
51+
52+ # Use “path” as the file to store the server info state. This is
53+ # used by “pumactl” to query and control the server.
54+ #
55+ # state_path '/u/apps/lolcat/tmp/pids/puma.state'
56+
57+ # Redirect STDOUT and STDERR to files specified. The 3rd parameter
58+ # (“append”) specifies whether the output is appended, the default is
59+ # “false”.
60+ #
61+ # stdout_redirect '/u/apps/lolcat/log/stdout', '/u/apps/lolcat/log/stderr'
62+ # stdout_redirect '/u/apps/lolcat/log/stdout', '/u/apps/lolcat/log/stderr', true
63+
64+ # Disable request logging.
65+ #
66+ # The default is “false”.
67+ #
68+ # quiet
69+
70+ # Configure “min” to be the minimum number of threads to use to answer
71+ # requests and “max” the maximum.
72+ #
73+ # The default is “0, 16”.
74+ #
75+ threads 0 , 16
76+
77+ # Bind the server to “url”. “tcp://”, “unix://” and “ssl://” are the only
78+ # accepted protocols.
79+ #
80+ # The default is “tcp://0.0.0.0:9292”.
81+ #
82+ bind 'tcp://0.0.0.0:8080'
83+ # bind 'unix:///var/run/puma.sock'
84+ # bind 'unix:///var/run/puma.sock?umask=0777'
85+ # bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'
86+
87+ # Instead of “bind 'ssl://127.0.0.1:9292?key=path_to_key&cert=path_to_cert'” you
88+ # can also use the “ssl_bind” option.
89+ #
90+ # ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert }
91+
92+ # Code to run before doing a restart. This code should
93+ # close log files, database connections, etc.
94+ #
95+ # This can be called multiple times to add code each time.
96+ #
97+ # on_restart do
98+ # puts 'On restart...'
99+ # end
100+
101+ # Command to use to restart puma. This should be just how to
102+ # load puma itself (ie. 'ruby -Ilib bin/puma'), not the arguments
103+ # to puma, as those are the same as the original process.
104+ #
105+ # restart_command '/u/app/lolcat/bin/restart_puma'
106+
107+ # === Cluster mode ===
108+
109+ # How many worker processes to run.
110+ #
111+ # The default is “0”.
112+ #
113+ workers 0
114+
115+ # Code to run when a worker boots to setup the process before booting
116+ # the app.
117+ #
118+ # This can be called multiple times to add hooks.
119+ #
120+ # on_worker_boot do
121+ # puts 'On worker boot...'
122+ # end
123+
124+ # === Puma control rack application ===
125+
126+ # Start the puma control rack application on “url”. This application can
127+ # be communicated with to control the main server. Additionally, you can
128+ # provide an authentication token, so all requests to the control server
129+ # will need to include that token as a query parameter. This allows for
130+ # simple authentication.
131+ #
132+ # Check out https://github.com/puma/puma/blob/master/lib/puma/app/status.rb
133+ # to see what the app has available.
134+ #
135+ # activate_control_app 'unix:///var/run/pumactl.sock'
136+ # activate_control_app 'unix:///var/run/pumactl.sock', { auth_token: '12345' }
137+ # activate_control_app 'unix:///var/run/pumactl.sock', { no_token: true }
0 commit comments