puma 3.2.0 → 3.3.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae407cb3f846ef2c3da83f997e42b4b0da3e6b9e
4
- data.tar.gz: 2e74ecbc15ed0a1363ad70d71605c69004b184ee
3
+ metadata.gz: 7069953b7e057c1aa73536b3aefccae709151c92
4
+ data.tar.gz: 50635cce883fd9a576b9db23a29c7a6a2d3a3526
5
5
  SHA512:
6
- metadata.gz: b66e244414a78a68ab0e841f10f531797098a19d054757b9e0d7cb2bceebe1e850a2e50aa73d9b096379a99e73b8a9d242afb5c477ecd2de2dddf7950d630404
7
- data.tar.gz: 52c7ac2681b0a73e58e2e1a2cf13d2e448248703dbcd630823c221423a4ae1564a71f28e10a4896ce9be2ab3e1c64a0ee2e0fab735c93bd9619e33dc08ef7f3d
6
+ metadata.gz: 347ecd7db9802483c8c8caf9dfd75acad3bd5d86b32fb47371a377764d685d9bfe2a36ae060643935b19007f5ba93b4cfbe0d531c3536de65dd7d2bfa72973ed
7
+ data.tar.gz: 8d33efdeeb7b842d79c4cb35228757910bdebca22928d282fb97c56d128ff5567bf7caefda0692ceca0e1669096918aa5993c11efc3e4caae7fd73654bb06101
@@ -1,3 +1,18 @@
1
+ === 3.3.0 / 2016-04-05
2
+
3
+ * 2 minor features:
4
+ * Allow overriding options of Configuration object
5
+ * Rename to inherit_ssl_listener like inherit_tcp|unix
6
+
7
+ * 2 doc fixes:
8
+ * Add docs/systemd.md (with socket activation sub-section)
9
+ * Document UNIX signals with cluster on README.md
10
+
11
+ * 3 PRs merged:
12
+ * Merge pull request #936 from prathamesh-sonpatki/allow-overriding-config-options
13
+ * Merge pull request #940 from kyledrake/signalsdoc
14
+ * Merge pull request #942 from dekellum/socket-activate-improve
15
+
1
16
  === 3.2.0 / 2016-03-20
2
17
 
3
18
  * 1 deprecation removal:
@@ -11,6 +11,7 @@ bin/pumactl
11
11
  docs/config.md
12
12
  docs/nginx.md
13
13
  docs/signals.md
14
+ docs/systemd.md
14
15
  ext/puma_http11/PumaHttp11Service.java
15
16
  ext/puma_http11/ext_help.h
16
17
  ext/puma_http11/extconf.rb
data/README.md CHANGED
@@ -252,6 +252,21 @@ But again beware, upgrading an application sometimes involves upgrading the data
252
252
 
253
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
254
 
255
+ ### Puma Signals
256
+
257
+ Puma cluster responds to these signals:
258
+
259
+ - `TTIN` increment the worker count by 1
260
+ - `TTOU` decrement the worker count by 1
261
+ - `TERM` send `TERM` to worker. Worker will attempt to finish then exit.
262
+ - `USR2` restart workers
263
+ - `USR1` restart workers in phases, a rolling restart.
264
+ - `HUP` reopen log files defined in stdout_redirect configuration parameter
265
+ - `INT` equivalent of sending Ctrl-C to cluster. Will attempt to finish then exit.
266
+ - `CHLD`
267
+
268
+ A detailed guide to using UNIX signals with Puma can be found in the [signals documentation](https://github.com/puma/puma/blob/master/docs/signals.md).
269
+
255
270
  ### Release Directory
256
271
 
257
272
  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.
@@ -0,0 +1,78 @@
1
+ # systemd
2
+
3
+ [systemd](https://www.freedesktop.org/wiki/Software/systemd/) is a
4
+ commonly available init system (PID 1) on many Linux distributions. It
5
+ offers process monitoring (including automatic restarts) and other
6
+ useful features for running Puma in production. Below is a sample
7
+ puma.service configuration file for systemd:
8
+
9
+ ~~~~
10
+ [Unit]
11
+ Description=Puma HTTP Server
12
+ After=network.target
13
+
14
+ [Service]
15
+ # Foreground process (do not use --daemon in ExecStart or config.rb)
16
+ Type=simple
17
+
18
+ # Preferably configure a non-privileged user
19
+ # User=
20
+
21
+ # Specify the path to your puma application root
22
+ # WorkingDirectory=
23
+
24
+ # Helpful for debugging socket activation, etc.
25
+ # Environment=PUMA_DEBUG=1
26
+
27
+ # The command to start Puma
28
+ # Here we are using a binstub generated via:
29
+ # `bundle binstubs puma --path ./sbin`
30
+ # in the WorkingDirectory (replace <WD> below)
31
+ # You can alternatively use `bundle exec --keep-file-descriptors puma`
32
+ # ExecStart=<WD>/sbin/puma -b tcp://0.0.0.0:9292 -b ssl://0.0.0.0:9293?key=key.pem&cert=cert.pem
33
+
34
+ # Alternatively with a config file (in WorkingDirectory) and
35
+ # comparable `bind` directives
36
+ # ExecStart=<WorkingDirectory>/sbin/puma -C config.rb
37
+
38
+ Restart=always
39
+
40
+ [Install]
41
+ WantedBy=multi-user.target
42
+ ~~~~
43
+
44
+ See [systemd.exec](https://www.freedesktop.org/software/systemd/man/systemd.exec.html)
45
+ for additional details.
46
+
47
+ ## Socket Activation
48
+
49
+ systemd and puma also support socket activation, where systemd opens
50
+ the listening socket(s) in advance and provides them to the puma master
51
+ process on startup. Among other advantages, this keeps listening
52
+ sockets open across puma restarts and achieves graceful restarts. To
53
+ use socket activation, configure one or more `ListenStream`
54
+ sockets in a companion `*.socket` systemd config file. Here is a sample
55
+ puma.socket, matching the ports used in the above puma.service:
56
+
57
+ ~~~~
58
+ [Unit]
59
+ Description=Puma HTTP Server Accept Sockets
60
+
61
+ [Socket]
62
+ ListenStream=0.0.0.0:9292
63
+ ListenStream=0.0.0.0:9293
64
+
65
+ # AF_UNIX domain socket
66
+ # SocketUser, SocketGroup, etc. may be needed for Unix domain sockets
67
+ # ListenStream=/run/puma.sock
68
+
69
+ # Socket options matching what Puma wants
70
+ NoDelay=true
71
+ ReusePort=true
72
+
73
+ [Install]
74
+ WantedBy=sockets.target
75
+ ~~~~
76
+
77
+ See [systemd.socket](https://www.freedesktop.org/software/systemd/man/systemd.socket.html)
78
+ for additional details.
@@ -11,6 +11,7 @@ module Puma
11
11
  @events = events
12
12
  @listeners = []
13
13
  @inherited_fds = {}
14
+ @activated_sockets = {}
14
15
  @unix_paths = []
15
16
 
16
17
  @proto_env = {
@@ -55,24 +56,23 @@ module Puma
55
56
  fd, url = v.split(":", 2)
56
57
  @inherited_fds[url] = fd.to_i
57
58
  remove << k
58
- end
59
- if k =~ /LISTEN_FDS/ && ENV['LISTEN_PID'].to_i == $$
59
+ elsif k == 'LISTEN_FDS' && ENV['LISTEN_PID'].to_i == $$
60
60
  v.to_i.times do |num|
61
61
  fd = num + 3
62
62
  sock = TCPServer.for_fd(fd)
63
63
  begin
64
- url = "unix://" + Socket.unpack_sockaddr_un(sock.getsockname)
64
+ key = [ :unix, Socket.unpack_sockaddr_un(sock.getsockname) ]
65
65
  rescue ArgumentError
66
66
  port, addr = Socket.unpack_sockaddr_in(sock.getsockname)
67
67
  if addr =~ /\:/
68
68
  addr = "[#{addr}]"
69
69
  end
70
- url = "tcp://#{addr}:#{port}"
70
+ key = [ :tcp, addr, port ]
71
71
  end
72
- @inherited_fds[url] = sock
72
+ @activated_sockets[key] = sock
73
+ @events.debug "Registered #{key.join ':'} for activation from LISTEN_FDS"
73
74
  end
74
- ENV.delete k
75
- ENV.delete 'LISTEN_PID'
75
+ remove << k << 'LISTEN_PID'
76
76
  end
77
77
  end
78
78
 
@@ -89,6 +89,9 @@ module Puma
89
89
  if fd = @inherited_fds.delete(str)
90
90
  logger.log "* Inherited #{str}"
91
91
  io = inherit_tcp_listener uri.host, uri.port, fd
92
+ elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ])
93
+ logger.log "* Activated #{str}"
94
+ io = inherit_tcp_listener uri.host, uri.port, sock
92
95
  else
93
96
  params = Util.parse_query uri.query
94
97
 
@@ -106,6 +109,9 @@ module Puma
106
109
  if fd = @inherited_fds.delete(str)
107
110
  logger.log "* Inherited #{str}"
108
111
  io = inherit_unix_listener path, fd
112
+ elsif sock = @activated_sockets.delete([ :unix, path ])
113
+ logger.log "* Activated #{str}"
114
+ io = inherit_unix_listener path, sock
109
115
  else
110
116
  logger.log "* Listening on #{str}"
111
117
 
@@ -191,7 +197,10 @@ module Puma
191
197
 
192
198
  if fd = @inherited_fds.delete(str)
193
199
  logger.log "* Inherited #{str}"
194
- io = inherited_ssl_listener fd, ctx
200
+ io = inherit_ssl_listener fd, ctx
201
+ elsif sock = @activated_sockets.delete([ :tcp, uri.host, uri.port ])
202
+ logger.log "* Activated #{str}"
203
+ io = inherit_ssl_listener sock, ctx
195
204
  else
196
205
  logger.log "* Listening on #{str}"
197
206
  io = add_ssl_listener uri.host, uri.port, ctx
@@ -209,12 +218,7 @@ module Puma
209
218
  logger.log "* Closing unused inherited connection: #{str}"
210
219
 
211
220
  begin
212
- if fd.kind_of? TCPServer
213
- fd.close
214
- else
215
- IO.for_fd(fd).close
216
- end
217
-
221
+ IO.for_fd(fd).close
218
222
  rescue SystemCallError
219
223
  end
220
224
 
@@ -226,6 +230,17 @@ module Puma
226
230
  end
227
231
  end
228
232
 
233
+ # Also close any unsued activated sockets
234
+ @activated_sockets.each do |key, sock|
235
+ logger.log "* Closing unused activated socket: #{key.join ':'}"
236
+ begin
237
+ sock.close
238
+ rescue SystemCallError
239
+ end
240
+ # We have to unlink a unix socket path that's not being used
241
+ File.unlink key[1] if key[0] == :unix
242
+ end
243
+
229
244
  end
230
245
 
231
246
  # Tell the server to listen on host +host+, port +port+.
@@ -285,11 +300,15 @@ module Puma
285
300
  s
286
301
  end
287
302
 
288
- def inherited_ssl_listener(fd, ctx)
303
+ def inherit_ssl_listener(fd, ctx)
289
304
  require 'puma/minissl'
290
305
  MiniSSL.check
291
306
 
292
- s = TCPServer.for_fd(fd)
307
+ if fd.kind_of? TCPServer
308
+ s = fd
309
+ else
310
+ s = TCPServer.for_fd(fd)
311
+ end
293
312
  ssl = MiniSSL::Server.new(s, ctx)
294
313
 
295
314
  env = @proto_env.dup
@@ -13,10 +13,10 @@ module Puma
13
13
  end
14
14
 
15
15
  class LeveledOptions
16
- def initialize(default={})
17
- @cur = {}
16
+ def initialize(default_options, user_options)
17
+ @cur = user_options
18
18
  @set = [@cur]
19
- @defaults = default.dup
19
+ @defaults = default_options.dup
20
20
  end
21
21
 
22
22
  def initialize_copy(other)
@@ -133,12 +133,9 @@ module Puma
133
133
  end
134
134
 
135
135
  def initialize(options={}, &blk)
136
- @options = LeveledOptions.new(default_options)
137
- @plugins = PluginLoader.new
136
+ @options = LeveledOptions.new(default_options, options)
138
137
 
139
- # options.each do |k,v|
140
- # @options[k] = v
141
- # end
138
+ @plugins = PluginLoader.new
142
139
 
143
140
  if blk
144
141
  configure(&blk)
@@ -100,8 +100,8 @@ module Puma
100
100
  # too taxing on performance.
101
101
  module Const
102
102
 
103
- PUMA_VERSION = VERSION = "3.2.0".freeze
104
- CODE_NAME = "Spring Is A Heliocentric Viewpoint".freeze
103
+ PUMA_VERSION = VERSION = "3.3.0".freeze
104
+ CODE_NAME = "Jovial Platypus".freeze
105
105
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
106
106
 
107
107
  FAST_TRACK_KA_TIMEOUT = 0.2
@@ -12,7 +12,7 @@ module Rack
12
12
  def self.run(app, options = {})
13
13
  options = DEFAULT_OPTIONS.merge(options)
14
14
 
15
- conf = ::Puma::Configuration.new do |c|
15
+ conf = ::Puma::Configuration.new(options) do |c|
16
16
  c.quiet
17
17
 
18
18
  if options.delete(:Verbose)
@@ -69,4 +69,3 @@ module Rack
69
69
  register :puma, Puma
70
70
  end
71
71
  end
72
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-20 00:00:00.000000000 Z
11
+ date: 2016-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '3.14'
67
+ version: '3.15'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '3.14'
74
+ version: '3.15'
75
75
  description: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server
76
76
  for Ruby/Rack applications. Puma is intended for use in both development and production
77
77
  environments. In order to get the best throughput, it is highly recommended that
@@ -91,6 +91,7 @@ extra_rdoc_files:
91
91
  - docs/config.md
92
92
  - docs/nginx.md
93
93
  - docs/signals.md
94
+ - docs/systemd.md
94
95
  - tools/jungle/README.md
95
96
  - tools/jungle/init.d/README.md
96
97
  - tools/jungle/upstart/README.md
@@ -108,6 +109,7 @@ files:
108
109
  - docs/config.md
109
110
  - docs/nginx.md
110
111
  - docs/signals.md
112
+ - docs/systemd.md
111
113
  - ext/puma_http11/PumaHttp11Service.java
112
114
  - ext/puma_http11/ext_help.h
113
115
  - ext/puma_http11/extconf.rb