puma 2.7.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puma might be problematic. Click here for more details.

Files changed (79) hide show
  1. checksums.yaml +5 -13
  2. data/DEPLOYMENT.md +91 -0
  3. data/Gemfile +3 -2
  4. data/History.txt +624 -1
  5. data/Manifest.txt +15 -3
  6. data/README.md +129 -14
  7. data/Rakefile +3 -3
  8. data/bin/puma-wild +31 -0
  9. data/bin/pumactl +1 -1
  10. data/docs/nginx.md +1 -1
  11. data/docs/signals.md +43 -0
  12. data/ext/puma_http11/extconf.rb +7 -2
  13. data/ext/puma_http11/http11_parser.java.rl +5 -5
  14. data/ext/puma_http11/io_buffer.c +1 -1
  15. data/ext/puma_http11/mini_ssl.c +233 -18
  16. data/ext/puma_http11/org/jruby/puma/Http11.java +12 -3
  17. data/ext/puma_http11/org/jruby/puma/Http11Parser.java +39 -39
  18. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +245 -195
  19. data/ext/puma_http11/puma_http11.c +12 -4
  20. data/lib/puma.rb +1 -0
  21. data/lib/puma/app/status.rb +7 -0
  22. data/lib/puma/binder.rb +108 -39
  23. data/lib/puma/capistrano.rb +23 -6
  24. data/lib/puma/cli.rb +141 -446
  25. data/lib/puma/client.rb +48 -1
  26. data/lib/puma/cluster.rb +207 -58
  27. data/lib/puma/commonlogger.rb +107 -0
  28. data/lib/puma/configuration.rb +262 -235
  29. data/lib/puma/const.rb +97 -14
  30. data/lib/puma/control_cli.rb +85 -77
  31. data/lib/puma/convenient.rb +23 -0
  32. data/lib/puma/daemon_ext.rb +11 -4
  33. data/lib/puma/detect.rb +8 -1
  34. data/lib/puma/dsl.rb +456 -0
  35. data/lib/puma/events.rb +35 -18
  36. data/lib/puma/jruby_restart.rb +1 -1
  37. data/lib/puma/launcher.rb +399 -0
  38. data/lib/puma/minissl.rb +49 -20
  39. data/lib/puma/null_io.rb +15 -0
  40. data/lib/puma/plugin.rb +104 -0
  41. data/lib/puma/plugin/tmp_restart.rb +35 -0
  42. data/lib/puma/rack/backports/uri/common_18.rb +56 -0
  43. data/lib/puma/rack/backports/uri/common_192.rb +52 -0
  44. data/lib/puma/rack/backports/uri/common_193.rb +29 -0
  45. data/lib/puma/rack/builder.rb +295 -0
  46. data/lib/puma/rack/urlmap.rb +90 -0
  47. data/lib/puma/reactor.rb +14 -1
  48. data/lib/puma/runner.rb +35 -17
  49. data/lib/puma/server.rb +161 -58
  50. data/lib/puma/single.rb +15 -10
  51. data/lib/puma/state_file.rb +29 -0
  52. data/lib/puma/thread_pool.rb +88 -13
  53. data/lib/puma/util.rb +123 -0
  54. data/lib/rack/handler/puma.rb +35 -29
  55. data/puma.gemspec +2 -4
  56. data/tools/jungle/init.d/README.md +2 -2
  57. data/tools/jungle/init.d/puma +69 -7
  58. data/tools/jungle/upstart/puma.conf +8 -2
  59. metadata +51 -71
  60. data/COPYING +0 -55
  61. data/TODO +0 -5
  62. data/lib/puma/rack_patch.rb +0 -45
  63. data/test/test_app_status.rb +0 -92
  64. data/test/test_cli.rb +0 -173
  65. data/test/test_config.rb +0 -16
  66. data/test/test_http10.rb +0 -27
  67. data/test/test_http11.rb +0 -145
  68. data/test/test_integration.rb +0 -165
  69. data/test/test_iobuffer.rb +0 -38
  70. data/test/test_minissl.rb +0 -25
  71. data/test/test_null_io.rb +0 -31
  72. data/test/test_persistent.rb +0 -238
  73. data/test/test_puma_server.rb +0 -292
  74. data/test/test_rack_handler.rb +0 -10
  75. data/test/test_rack_server.rb +0 -141
  76. data/test/test_tcp_rack.rb +0 -42
  77. data/test/test_thread_pool.rb +0 -156
  78. data/test/test_unix_socket.rb +0 -39
  79. data/test/test_ws.rb +0 -89
data/Manifest.txt CHANGED
@@ -1,15 +1,16 @@
1
- COPYING
1
+ DEPLOYMENT.md
2
2
  Gemfile
3
3
  History.txt
4
4
  LICENSE
5
5
  Manifest.txt
6
6
  README.md
7
7
  Rakefile
8
- TODO
9
8
  bin/puma
9
+ bin/puma-wild
10
10
  bin/pumactl
11
11
  docs/config.md
12
12
  docs/nginx.md
13
+ docs/signals.md
13
14
  ext/puma_http11/PumaHttp11Service.java
14
15
  ext/puma_http11/ext_help.h
15
16
  ext/puma_http11/extconf.rb
@@ -32,25 +33,36 @@ lib/puma/capistrano.rb
32
33
  lib/puma/cli.rb
33
34
  lib/puma/client.rb
34
35
  lib/puma/cluster.rb
36
+ lib/puma/commonlogger.rb
35
37
  lib/puma/compat.rb
36
38
  lib/puma/configuration.rb
37
39
  lib/puma/const.rb
38
40
  lib/puma/control_cli.rb
41
+ lib/puma/convenient.rb
39
42
  lib/puma/daemon_ext.rb
40
43
  lib/puma/delegation.rb
41
44
  lib/puma/detect.rb
45
+ lib/puma/dsl.rb
42
46
  lib/puma/events.rb
43
47
  lib/puma/io_buffer.rb
44
48
  lib/puma/java_io_buffer.rb
45
49
  lib/puma/jruby_restart.rb
50
+ lib/puma/launcher.rb
46
51
  lib/puma/minissl.rb
47
52
  lib/puma/null_io.rb
53
+ lib/puma/plugin.rb
54
+ lib/puma/plugin/tmp_restart.rb
55
+ lib/puma/rack/backports/uri/common_18.rb
56
+ lib/puma/rack/backports/uri/common_192.rb
57
+ lib/puma/rack/backports/uri/common_193.rb
58
+ lib/puma/rack/builder.rb
59
+ lib/puma/rack/urlmap.rb
48
60
  lib/puma/rack_default.rb
49
- lib/puma/rack_patch.rb
50
61
  lib/puma/reactor.rb
51
62
  lib/puma/runner.rb
52
63
  lib/puma/server.rb
53
64
  lib/puma/single.rb
65
+ lib/puma/state_file.rb
54
66
  lib/puma/tcp_logger.rb
55
67
  lib/puma/thread_pool.rb
56
68
  lib/puma/util.rb
data/README.md CHANGED
@@ -1,6 +1,9 @@
1
1
  # Puma: A Ruby Web Server Built For Concurrency
2
2
 
3
- [![Build Status](https://secure.travis-ci.org/puma/puma.png)](http://travis-ci.org/puma/puma) [![Dependency Status](https://gemnasium.com/puma/puma.png)](https://gemnasium.com/puma/puma)
3
+ [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/puma/puma?utm\_source=badge&utm\_medium=badge&utm\_campaign=pr-badge)
4
+ [![Build Status](https://secure.travis-ci.org/puma/puma.svg)](http://travis-ci.org/puma/puma)
5
+ [![Dependency Status](https://gemnasium.com/puma/puma.svg)](https://gemnasium.com/puma/puma)
6
+ [![Code Climate](https://codeclimate.com/github/puma/puma.svg)](https://codeclimate.com/github/puma/puma)
4
7
 
5
8
  ## Description
6
9
 
@@ -26,6 +29,36 @@ Now you should have the `puma` command available in your PATH, so just do the fo
26
29
 
27
30
  $ puma app.ru
28
31
 
32
+ ## Plugins
33
+
34
+ Puma 3.0 added support for plugins that can augment configuration and service operations.
35
+
36
+ 2 canonical plugins to look to aid in development of further plugins:
37
+
38
+ * [tmp\_restart](https://github.com/puma/puma/blob/master/lib/puma/plugin/tmp_restart.rb): Restarts the server if the file `tmp/restart.txt` is touched
39
+ * [heroku](https://github.com/puma/puma-heroku/blob/master/lib/puma/plugin/heroku.rb): Packages up the default configuration used by puma on Heroku
40
+
41
+ Plugins are activated in a puma configuration file (such as `config/puma.rb'`) by adding `plugin "name"`, such as `plugin "heroku"`.
42
+
43
+ Plugins are activated based simply on path requirements so, activating the `heroku` plugin will simply be doing `require "puma/plugin/heroku"`. This allows gems to provide multiple plugins (as well as unrelated gems to provide puma plugins).
44
+
45
+ The `tmp_restart` plugin is bundled with puma, so it can always be used.
46
+
47
+ To use the `heroku` plugin, add `puma-heroku` to your Gemfile or install it.
48
+
49
+ ### API
50
+
51
+ At present, there are 2 hooks that plugins can use: `start` and `config`.
52
+
53
+ `start` runs when the server has started and allows the plugin to start other functionality to augment puma.
54
+
55
+ `config` runs when the server is being configured and is passed a `Puma::DSL` object that can be used to add additional configuration.
56
+
57
+ Any public methods in `Puma::Plugin` are the public API that any plugin may use.
58
+
59
+ In the future, more hooks and APIs will be added.
60
+
61
+
29
62
  ## Advanced Setup
30
63
 
31
64
  ### Sinatra
@@ -71,7 +104,7 @@ Puma utilizes a dynamic thread pool which you can modify. You can set the minimu
71
104
 
72
105
  $ puma -t 8:32
73
106
 
74
- Puma will automatically scale the number of threads based on how much traffic is present. The current default is `0:16`. Feel free to experiment, but be careful not to set the number of maximum threads to a very large number, as you may exhaust resources on the system (or hit resource limits).
107
+ Puma will automatically scale the number of threads, from the minimum until it caps out at the maximum, based on how much traffic is present. The current default is `0:16`. Feel free to experiment, but be careful not to set the number of maximum threads to a very large number, as you may exhaust resources on the system (or hit resource limits).
75
108
 
76
109
  ### Clustered mode
77
110
 
@@ -82,7 +115,7 @@ Puma 2 offers clustered mode, allowing you to use forked processes to handle mul
82
115
  On a ruby implementation that offers native threads, you should tune this number to match the number of cores available.
83
116
  Note that threads are still used in clustered mode, and the `-t` thread flag setting is per worker, so `-w 2 -t 16:16` will be 32 threads.
84
117
 
85
- If you're running in Clustered Mode you can optionally choose to preload your application before starting up the workers. This is necessary in order to take advantate of the [Copy on Write](http://en.wikipedia.org/wiki/Copy-on-write) feature introduced in [MRI Ruby 2.0](https://blog.heroku.com/archives/2013/3/6/matz_highlights_ruby_2_0_at_waza). To do this simply specify the `--preload` flag in invocation:
118
+ If you're running in Clustered Mode you can optionally choose to preload your application before starting up the workers. This is necessary in order to take advantage of the [Copy on Write](http://en.wikipedia.org/wiki/Copy-on-write) feature introduced in [MRI Ruby 2.0](https://blog.heroku.com/archives/2013/3/6/matz_highlights_ruby_2_0_at_waza). To do this simply specify the `--preload` flag in invocation:
86
119
 
87
120
  # CLI invocation
88
121
  $ puma -t 8:32 -w 3 --preload
@@ -108,7 +141,7 @@ you to do some Puma-specific things that you don't want to embed in your applica
108
141
  For instance, you could fire a log notification that a worker booted or send something to statsd.
109
142
  This can be called multiple times to add hooks.
110
143
 
111
- If you're preloading your application and using ActiveRecord, it's recommend you setup your connection pool here:
144
+ If you're preloading your application and using ActiveRecord, it's recommended that you setup your connection pool here:
112
145
 
113
146
  # config/puma.rb
114
147
  on_worker_boot do
@@ -117,6 +150,43 @@ If you're preloading your application and using ActiveRecord, it's recommend you
117
150
  end
118
151
  end
119
152
 
153
+ On top of that, you can specify a block in your configuration file that will be run before workers are forked
154
+
155
+ # config/puma.rb
156
+ before_fork do
157
+ # configuration here
158
+ end
159
+
160
+ This code can be used to clean up before forking to clients, allowing
161
+ you to do some Puma-specific things that you don't want to embed in your application.
162
+
163
+ If you're preloading your application and using ActiveRecord, it's recommended that you close any connections to the database here to prevent connection leakage:
164
+
165
+ # config/puma.rb
166
+ before_fork do
167
+ ActiveRecord::Base.connection_pool.disconnect!
168
+ end
169
+
170
+ This rule applies to any connections to external services (Redis, databases, memcache, ...) that might be started automatically by the framework.
171
+
172
+ When you use preload_app, all of your new code goes into the master process, and is then copied into the workers (meaning it’s only compatible with cluster mode). General rule is to use preload_app when your workers die often and need fast starts. If you don’t have many workers, you probably should not use preload_app.
173
+
174
+ Note that preload_app can’t be used with phased restart, since phased restart kills and restarts workers one-by-one, and preload_app is all about copying the code of master into the workers.
175
+
176
+ ### Error handler for low-level errors
177
+
178
+ If puma encounters an error outside of the context of your application, it will respond with a 500 and a simple
179
+ textual error message (see `lowlevel_error` in [this file](https://github.com/puma/puma/blob/master/lib/puma/server.rb)).
180
+ You can specify custom behavior for this scenario. For example, you can report the error to your third-party
181
+ error-tracking service (in this example, [rollbar](http://rollbar.com)):
182
+
183
+ ```ruby
184
+ lowlevel_error_handler do |e|
185
+ Rollbar.critical(e)
186
+ [500, {}, ["An error has occurred, and engineers have been informed. Please reload the page. If you continue to have problems, contact support@example.com\n"]]
187
+ end
188
+ ```
189
+
120
190
  ### Binding TCP / Sockets
121
191
 
122
192
  In contrast to many other server configs which require multiple flags, Puma simply uses one URI parameter with the `-b` (or `--bind`) flag:
@@ -129,7 +199,7 @@ Want to use UNIX Sockets instead of TCP (which can provide a 5-10% performance b
129
199
 
130
200
  If you need to change the permissions of the UNIX socket, just add a umask parameter:
131
201
 
132
- $ puma -b 'unix:///var/run/puma.sock?umask=0777'
202
+ $ puma -b 'unix:///var/run/puma.sock?umask=0111'
133
203
 
134
204
  Need a bit of security? Use SSL sockets!
135
205
 
@@ -137,7 +207,7 @@ Need a bit of security? Use SSL sockets!
137
207
 
138
208
  ### Control/Status Server
139
209
 
140
- Puma comes with a builtin status/control app that can be used query and control Puma itself. Here is an example of starting Puma with the control server:
210
+ Puma comes with a builtin status/control app that can be used to query and control Puma itself. Here is an example of starting Puma with the control server:
141
211
 
142
212
  $ puma --control tcp://127.0.0.1:9293 --control-token foo
143
213
 
@@ -149,6 +219,12 @@ You can also provide a configuration file which Puma will use with the `-C` (or
149
219
 
150
220
  $ puma -C /path/to/config
151
221
 
222
+ By default, if no configuration file is specified, Puma will look for a configuration file at config/puma.rb. If an environment is specified, either via the `-e` and `--environment` flags, or through the `RACK_ENV` environment variable, the default file location will be config/puma/environment_name.rb.
223
+
224
+ If you want to prevent Puma from looking for a configuration file in those locations, provide a dash as the argument to the `-C` (or `--config`) flag:
225
+
226
+ $ puma -C "-"
227
+
152
228
  Take the following [sample configuration](https://github.com/puma/puma/blob/master/examples/config.rb) as inspiration or check out [configuration.rb](https://github.com/puma/puma/blob/master/lib/puma/configuration.rb) to see all available options.
153
229
 
154
230
  ## Restart
@@ -164,15 +240,37 @@ No code is shared between the current and restarted process, so it should be saf
164
240
 
165
241
  If the new process is unable to load, it will simply exit. You should therefore run Puma under a supervisor when using it in production.
166
242
 
243
+ ### Normal vs Hot vs Phased Restart
244
+
245
+ A hot restart means that no requests will be lost while deploying your new code, since the server socket is kept open between restarts.
246
+
247
+ But beware, hot restart does not mean that the incoming requests won’t hang for multiple seconds while your new code has not fully deployed. If you need a zero downtime and zero hanging requests deploy, you must use phased restart.
248
+
249
+ When you run pumactl phased-restart, Puma kills workers one-by-one, meaning that at least another worker is still available to serve requests, which lead to zero hanging requests (yay!).
250
+
251
+ But again beware, upgrading an application sometimes involves upgrading the database schema. With phased restart, there may be a moment during the deployment where processes belonging to the previous version and processes belonging to the new version both exist at the same time. Any database schema upgrades you perform must therefore be backwards-compatible with the old application version.
252
+
253
+ If you perform a lot of database migrations, you probably should not use phased restart and use a normal/hot restart instead (pumactl restart). That way, no code is shared while deploying (in that case, preload_app might help for quicker deployment, see below).
254
+
255
+ ### Release Directory
256
+
257
+ If you symlink releases into a common working directory (i.e., `/current` from Capistrano), Puma won't pick up your new changes when running phased restarts without additional configuration. You should set your working directory within Puma's config to specify the directory it should use. This is a change from earlier versions of Puma (< 2.15) that would infer the directory for you.
258
+
259
+ ```ruby
260
+ # config/puma.rb
261
+
262
+ directory '/var/www/current'
263
+ ```
264
+
167
265
  ### Cleanup Code
168
266
 
169
267
  Puma isn't able to understand all the resources that your app may use, so it provides a hook in the configuration file you pass to `-C` called `on_restart`. The block passed to `on_restart` will be called, unsurprisingly, just before Puma restarts itself.
170
268
 
171
- You should place code to close global log files, redis connections, etc in this block so that their file descriptors don't leak into the restarted process. Failure to do so will result in slowly running out of descriptors and eventually obscure crashes as the server is restart many times.
269
+ You should place code to close global log files, redis connections, etc in this block so that their file descriptors don't leak into the restarted process. Failure to do so will result in slowly running out of descriptors and eventually obscure crashes as the server is restarted many times.
172
270
 
173
271
  ### Platform Constraints
174
272
 
175
- Because of various platforms not being implement certain things, the following differences occur when Puma is used on different platforms:
273
+ Because of various platforms not being able to implement certain things, the following differences occur when Puma is used on different platforms:
176
274
 
177
275
  * **JRuby**, **Windows**: server sockets are not seamless on restart, they must be closed and reopened. These platforms have no way to pass descriptors into a new process that is exposed to ruby
178
276
  * **JRuby**, **Windows**: cluster mode is not supported due to a lack of fork(2)
@@ -184,16 +282,25 @@ Because of various platforms not being implement certain things, the following d
184
282
 
185
283
  ## Managing multiple Pumas / init.d / upstart scripts
186
284
 
187
- If you want an easy way to manage multiple scripts at once check [tools/jungle](https://github.com/puma/puma/tree/master/tools/jungle) for init.d and upstart scripts.
285
+ If you want an easy way to manage multiple scripts at once, check [tools/jungle](https://github.com/puma/puma/tree/master/tools/jungle) for init.d and upstart scripts.
188
286
 
189
287
  ## Capistrano deployment
190
288
 
191
- Puma has included Capistrano [deploy script](https://github.com/puma/puma/blob/master/lib/puma/capistrano.rb), you just need require that:
289
+ Puma has support for Capistrano3 with an [external gem](https://github.com/seuros/capistrano-puma), you just need require that in Gemfile:
290
+
291
+ ```ruby
292
+ gem 'capistrano3-puma'
293
+ ```
294
+ And then execute:
295
+
296
+ ```bash
297
+ bundle
298
+ ```
192
299
 
193
- config/deploy.rb
300
+ Then add to Capfile
194
301
 
195
302
  ```ruby
196
- require 'puma/capistrano'
303
+ require 'capistrano/puma'
197
304
  ```
198
305
 
199
306
  and then
@@ -202,10 +309,18 @@ and then
202
309
  $ bundle exec cap puma:start
203
310
  $ bundle exec cap puma:restart
204
311
  $ bundle exec cap puma:stop
205
- $ bundle exec cap puma:phased_restart
312
+ $ bundle exec cap puma:phased-restart
206
313
  ```
207
314
 
315
+ ## Contributing
316
+
317
+ To run the test suite:
318
+
319
+ ```bash
320
+ $ bundle install
321
+ $ bundle exec rake
322
+ ```
208
323
 
209
324
  ## License
210
325
 
211
- Puma is copyright 2013 Evan Phoenix and contributors. It is licensed under the BSD license. See the include LICENSE file for details.
326
+ Puma is copyright 2014 Evan Phoenix and contributors. It is licensed under the BSD 3-Clause license. See the included LICENSE file for details.
data/Rakefile CHANGED
@@ -8,10 +8,10 @@ Hoe.plugin :git
8
8
  Hoe.plugin :ignore
9
9
 
10
10
  HOE = Hoe.spec "puma" do
11
- self.rubyforge_name = 'puma'
12
11
  self.readme_file = "README.md"
13
12
  self.urls = %w!http://puma.io https://github.com/puma/puma!
14
13
 
14
+ license "BSD-3-Clause"
15
15
  developer 'Evan Phoenix', 'evan@phx.io'
16
16
 
17
17
  spec_extras[:extensions] = ["ext/puma_http11/extconf.rb"]
@@ -20,9 +20,9 @@ HOE = Hoe.spec "puma" do
20
20
 
21
21
  require_ruby_version ">= 1.8.7"
22
22
 
23
- dependency "rack", [">= 1.1", "< 2.0"]
23
+ dependency "rack", [">= 1.1", "< 2.0"], :development
24
24
 
25
- extra_dev_deps << ["rake-compiler", "~> 0.8.0"]
25
+ extra_dev_deps << ["rake-compiler", "~> 0.8"]
26
26
  end
27
27
 
28
28
  task :prerelease => [:clobber, :check_manifest, :test]
data/bin/puma-wild ADDED
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Copyright (c) 2014 Evan Phoenix
4
+ #
5
+
6
+ require 'rubygems'
7
+
8
+ gems = ARGV.shift
9
+
10
+ inc = ""
11
+
12
+ if gems == "-I"
13
+ inc = ARGV.shift
14
+ $LOAD_PATH.concat inc.split(":")
15
+ gems = ARGV.shift
16
+ end
17
+
18
+ gems.split(",").each do |s|
19
+ name, ver = s.split(":",2)
20
+ gem name, ver
21
+ end
22
+
23
+ module Puma; end
24
+
25
+ Puma.const_set("WILD_ARGS", ["-I", inc, gems])
26
+
27
+ require 'puma/cli'
28
+
29
+ cli = Puma::CLI.new ARGV
30
+
31
+ cli.run
data/bin/pumactl CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'puma/control_cli'
4
4
 
5
- cli = Puma::ControlCLI.new ARGV
5
+ cli = Puma::ControlCLI.new ARGV.dup
6
6
 
7
7
  begin
8
8
  cli.run
data/docs/nginx.md CHANGED
@@ -40,7 +40,7 @@ server {
40
40
  }
41
41
 
42
42
  # check for index.html for directory index
43
- # if its there on the filesystem then rewite
43
+ # if it's there on the filesystem then rewrite
44
44
  # the url to add /index.html to the end of it
45
45
  # and then break to send it to the next config rules.
46
46
  if (-f $request_filename/index.html) {
data/docs/signals.md ADDED
@@ -0,0 +1,43 @@
1
+ The [unix signal](http://en.wikipedia.org/wiki/Unix_signal) is a method of sending messages between [processes](http://en.wikipedia.org/wiki/Process_(computing)). When a signal is sent, the operating system interrupts the target process's normal flow of execution. There are standard signals that are used to stop a process but there are also custom signals that can be used for other purposes. This document is an attempt to list all supported signals that Puma will respond to. In general, signals need only be sent to the master process of a cluster.
2
+
3
+ ## Sending Signals
4
+
5
+ If you are new to signals it can be useful to see how they can be used. When a process is created in a *nix like operating system it will have a [PID - or process identifier](http://en.wikipedia.org/wiki/Process_identifier) that can be used to send signals to the process. For demonstration we will create an infinitely running process by tailing a file:
6
+
7
+ ```sh
8
+ $ echo "foo" >> my.log
9
+ $ irb
10
+ > pid = Process.spawn 'tail -f my.log'
11
+ ```
12
+
13
+ From here we can see that the tail process is running by using the `ps` command:
14
+
15
+ ```sh
16
+ $ ps aux | grep tail
17
+ schneems 87152 0.0 0.0 2432772 492 s032 S+ 12:46PM 0:00.00 tail -f my.log
18
+ ```
19
+
20
+ You can send a signal in Ruby using the [Process module](http://www.ruby-doc.org/core-2.1.1/Process.html#kill-method):
21
+
22
+ ```
23
+ $ irb
24
+ > puts pid
25
+ => 87152
26
+ Process.detach(pid) # http://ruby-doc.org/core-2.1.1/Process.html#method-c-detach
27
+ Process.kill("TERM", pid)
28
+ ```
29
+
30
+ Now you will see via `ps` that there is no more `tail` process. Sometimes when referring to signals the `SIG` prefix will be used for instance `SIGTERM` is equivalent to sending `TERM` via `Process.kill`.
31
+
32
+ ## Puma Signals
33
+
34
+ Puma cluster responds to these signals:
35
+
36
+ - `TTIN` increment the worker count by 1
37
+ - `TTOU` decrement the worker count by 1
38
+ - `TERM` send `TERM` to worker. Worker will attempt to finish then exit.
39
+ - `USR2` restart workers
40
+ - `USR1` restart workers in phases, a rolling restart.
41
+ - `HUP` reopen log files defined in stdout_redirect configuration parameter
42
+ - `INT` equivalent of sending Ctrl-C to cluster. Will attempt to finish then exit.
43
+ - `CHLD`
@@ -2,7 +2,12 @@ require 'mkmf'
2
2
 
3
3
  dir_config("puma_http11")
4
4
 
5
- $defs.push "-Wno-deprecated-declarations"
6
- $libs += " -lssl -lcrypto "
5
+ unless ENV["DISABLE_SSL"]
6
+ if %w'crypto libeay32'.find {|crypto| have_library(crypto, 'BIO_read')} and
7
+ %w'ssl ssleay32'.find {|ssl| have_library(ssl, 'SSL_CTX_new')}
8
+
9
+ have_header "openssl/bio.h"
10
+ end
11
+ end
7
12
 
8
13
  create_makefile("puma/puma_http11")
@@ -7,8 +7,8 @@ public class Http11Parser {
7
7
  /** Machine **/
8
8
 
9
9
  %%{
10
-
11
- machine http_parser;
10
+
11
+ machine puma_parser;
12
12
 
13
13
  action mark {parser.mark = fpc; }
14
14
 
@@ -60,7 +60,7 @@ public class Http11Parser {
60
60
  fbreak;
61
61
  }
62
62
 
63
- include http_parser_common "http11_parser_common.rl";
63
+ include puma_parser_common "http11_parser_common.rl";
64
64
 
65
65
  }%%
66
66
 
@@ -152,10 +152,10 @@ public class Http11Parser {
152
152
  }
153
153
 
154
154
  public boolean has_error() {
155
- return parser.cs == http_parser_error;
155
+ return parser.cs == puma_parser_error;
156
156
  }
157
157
 
158
158
  public boolean is_finished() {
159
- return parser.cs == http_parser_first_final;
159
+ return parser.cs == puma_parser_first_final;
160
160
  }
161
161
  }