puma 3.11.3 → 3.11.4

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
- SHA1:
3
- metadata.gz: 4804608b8eb91d9bfd64c81497f624c5c623fdda
4
- data.tar.gz: 76eac44fc46d7a7d53fc83d5d67eb0d1cdbb14c3
2
+ SHA256:
3
+ metadata.gz: 7f451a7278034b23b2a1537d6bde82ae318cd58750dbab2c0a6aa4eb0e72efb0
4
+ data.tar.gz: 3841d52680598006e72b92c37c358d0f185980bfca81cdc55c19e25673156f61
5
5
  SHA512:
6
- metadata.gz: 0ffda6912f5ab5aad0cd430dcfb73b8f4ac97764c205b6396ff545d7672ab828f626da30e881a8789a4dcee5e8a4346e383a3b69569cc2be7bde604165251c0a
7
- data.tar.gz: ef1bc4ef2372bfec240b4a36f60035c978ba45c8423db18c7372c3ca0f52a7dc90ba83ef9dfa2a5b20f85a832d0f4ba9a5ced2d41a165a6bd8b49d021c007721
6
+ metadata.gz: 6273588bb47a3f85b40a358dc445733de687707111dd5aaffe4004be32a82eef00c227495abd9e68bd0b3f398395b64b685e8b78f5b428e3aee87be50f91cb1f
7
+ data.tar.gz: 167dc9b6bdcf05050cff4d80af977ede8c4cd9b5fb0dd3397f8075e4657402cf5e7e084c248c2e23d06669cbce52cd13a84155612a3451c0ac5df6d0cff36730
data/History.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 3.11.4 / 2018-04-12
2
+
3
+ * 2 features:
4
+ * Manage puma as a service using rc.d (#1529)
5
+ * Server stats are now available from a top level method (#1532)
6
+ * 5 bugfixes:
7
+ * Fix parsing CLI options (#1482)
8
+ * Order of stderr and stdout is made before redirecting to a log file (#1511)
9
+ * Init.d fix of `ps -p` to check if pid exists (#1545)
10
+ * Early hits bugfix (#1550)
11
+ * Purge interrupt queue when closing socket fails (#1553)
12
+
1
13
  ## 3.11.3 / 2018-03-05
2
14
 
3
15
  * 3 bugfixes:
data/README.md CHANGED
@@ -217,10 +217,10 @@ Some platforms do not support all Puma features.
217
217
 
218
218
  ## Known Bugs
219
219
 
220
- For MRI versions 2.2.7, 2.2.8, 2.3.4 and 2.4.1, you may see ```stream closed in another thread (IOError)```. It may be caused by a [Ruby bug](https://bugs.ruby-lang.org/issues/13632). It can be fixed with the gem https://rubygems.org/gems/stopgap_13632:
220
+ For MRI versions 2.2.7, 2.2.8, 2.2.9, 2.3.4 and 2.4.1, you may see ```stream closed in another thread (IOError)```. It may be caused by a [Ruby bug](https://bugs.ruby-lang.org/issues/13632). It can be fixed with the gem https://rubygems.org/gems/stopgap_13632:
221
221
 
222
222
  ```ruby
223
- if %w(2.2.7 2.2.8 2.3.4 2.4.1).include? RUBY_VERSION
223
+ if %w(2.2.7 2.2.8 2.2.9 2.3.4 2.4.1).include? RUBY_VERSION
224
224
  begin
225
225
  require 'stopgap_13632'
226
226
  rescue LoadError
@@ -33,4 +33,4 @@ Clustered mode is shown/discussed here. Single mode is analogous to having a sin
33
33
  The `queue_requests` option is `true` by default, enabling the separate thread used to buffer requests as described above.
34
34
 
35
35
  If set to `false`, this buffer will not be used for connections while waiting for the request to arrive.
36
- In this mode, when a connection is accepted, it is added to the "todo" queue immediately, and a worker will syncronously do any waiting necessarry to read the HTTP request from the socket.
36
+ In this mode, when a connection is accepted, it is added to the "todo" queue immediately, and a worker will synchronously do any waiting necessary to read the HTTP request from the socket.
@@ -20,7 +20,7 @@ When you run pumactl phased-restart, Puma kills workers one-by-one, meaning that
20
20
 
21
21
  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.
22
22
 
23
- 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).
23
+ 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 ["Clustered Mode" in the README](../README.md#clustered-mode)).
24
24
 
25
25
  ### Release Directory
26
26
 
@@ -102,6 +102,16 @@ for additional configuration details.
102
102
  Note that the above configurations will work with Puma in either
103
103
  single process or cluster mode.
104
104
 
105
+ ### Sockets and symlinks
106
+
107
+ When using releases folders, you should set the socket path using the
108
+ shared folder path (ex. `/srv/projet/shared/tmp/puma.sock`), not the
109
+ release folder path (`/srv/projet/releases/1234/tmp/puma.sock`).
110
+
111
+ Puma will detect the release path socket as different than the one provided by
112
+ systemd and attempt to bind it again, resulting in the exception
113
+ `There is already a server bound to:`.
114
+
105
115
  ## Usage
106
116
 
107
117
  Without socket activation, use `systemctl` as root (e.g. via `sudo`) as
@@ -12,4 +12,12 @@ module Puma
12
12
  autoload :Const, 'puma/const'
13
13
  autoload :Server, 'puma/server'
14
14
  autoload :Launcher, 'puma/launcher'
15
+
16
+ def self.stats_object=(val)
17
+ @get_stats = val
18
+ end
19
+
20
+ def self.stats
21
+ @get_stats.stats
22
+ end
15
23
  end
@@ -1,6 +1,7 @@
1
1
  require 'optparse'
2
2
  require 'uri'
3
3
 
4
+ require 'puma'
4
5
  require 'puma/configuration'
5
6
  require 'puma/launcher'
6
7
  require 'puma/const'
@@ -98,7 +98,7 @@ module Puma
98
98
  # too taxing on performance.
99
99
  module Const
100
100
 
101
- PUMA_VERSION = VERSION = "3.11.3".freeze
101
+ PUMA_VERSION = VERSION = "3.11.4".freeze
102
102
  CODE_NAME = "Love Song".freeze
103
103
  PUMA_SERVER_STRING = ['puma', PUMA_VERSION, CODE_NAME].join(' ').freeze
104
104
 
@@ -69,6 +69,7 @@ module Puma
69
69
  end
70
70
 
71
71
  opts.order!(argv) { |a| opts.terminate a }
72
+ opts.parse!
72
73
 
73
74
  @command = argv.shift
74
75
 
@@ -204,7 +205,6 @@ module Puma
204
205
  Process.kill "SIGUSR1", @pid
205
206
 
206
207
  else
207
- message "Puma is started"
208
208
  return
209
209
  end
210
210
 
@@ -146,13 +146,13 @@ module Puma
146
146
  # them
147
147
  #
148
148
  def persistent_timeout(seconds)
149
- @options[:persistent_timeout] = seconds
149
+ @options[:persistent_timeout] = Integer(seconds)
150
150
  end
151
151
 
152
152
  # Define how long the tcp socket stays open, if no data has been received
153
153
  #
154
154
  def first_data_timeout(seconds)
155
- @options[:first_data_timeout] = seconds
155
+ @options[:first_data_timeout] = Integer(seconds)
156
156
  end
157
157
 
158
158
  # Work around leaky apps that leave garbage in Thread locals
@@ -169,7 +169,7 @@ module Puma
169
169
  end
170
170
 
171
171
  # When shutting down, drain the accept socket of pending
172
- # connections and proces them. This loops over the accept
172
+ # connections and process them. This loops over the accept
173
173
  # socket until there are no more read events and then stops
174
174
  # looking and waits for the requests to finish.
175
175
  def drain_on_shutdown(which=true)
@@ -424,17 +424,17 @@ module Puma
424
424
  # that have not checked in within the given +timeout+.
425
425
  # This mitigates hung processes. Default value is 60 seconds.
426
426
  def worker_timeout(timeout)
427
- @options[:worker_timeout] = timeout
427
+ @options[:worker_timeout] = Integer(timeout)
428
428
  end
429
429
 
430
430
  # *Cluster mode only* Set the timeout for workers to boot
431
431
  def worker_boot_timeout(timeout)
432
- @options[:worker_boot_timeout] = timeout
432
+ @options[:worker_boot_timeout] = Integer(timeout)
433
433
  end
434
434
 
435
435
  # *Cluster mode only* Set the timeout for worker shutdown
436
436
  def worker_shutdown_timeout(timeout)
437
- @options[:worker_shutdown_timeout] = timeout
437
+ @options[:worker_shutdown_timeout] = Integer(timeout)
438
438
  end
439
439
 
440
440
  # When set to true (the default), workers accept all requests
@@ -86,6 +86,7 @@ module Puma
86
86
  else
87
87
  @runner = Single.new(self, @events)
88
88
  end
89
+ Puma.stats_object = @runner
89
90
 
90
91
  @status = :run
91
92
  end
@@ -249,7 +249,7 @@ module Puma
249
249
  end
250
250
 
251
251
  def close
252
- @socket.close
252
+ @socket.close unless @socket.closed? # closed? call is for Windows
253
253
  end
254
254
  end
255
255
  end
@@ -220,7 +220,11 @@ module Puma
220
220
  # nothing
221
221
  rescue Errno::ECONNABORTED
222
222
  # client closed the socket even before accept
223
- io.close rescue nil
223
+ begin
224
+ io.close
225
+ rescue
226
+ Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
227
+ end
224
228
  end
225
229
  end
226
230
  end
@@ -372,7 +376,11 @@ module Puma
372
376
  # nothing
373
377
  rescue Errno::ECONNABORTED
374
378
  # client closed the socket even before accept
375
- io.close rescue nil
379
+ begin
380
+ io.close
381
+ rescue
382
+ Thread.current.purge_interrupt_queue if Thread.current.respond_to? :purge_interrupt_queue
383
+ end
376
384
  end
377
385
  end
378
386
  end
@@ -606,7 +614,7 @@ module Puma
606
614
  fast_write client, "#{k}: #{v}\r\n"
607
615
  end
608
616
  else
609
- fast_write client, "#{k}: #{v}\r\n"
617
+ fast_write client, "#{k}: #{vs}\r\n"
610
618
  end
611
619
  end
612
620
 
@@ -9,6 +9,7 @@ module Rack
9
9
  }
10
10
 
11
11
  def self.config(app, options = {})
12
+ require 'puma'
12
13
  require 'puma/configuration'
13
14
  require 'puma/events'
14
15
  require 'puma/launcher'
@@ -1,9 +1,5 @@
1
1
  # Puma as a service
2
2
 
3
- ## Init.d
4
-
5
- See `/tools/jungle/init.d` for tools to use with init.d and start-stop-daemon.
6
-
7
3
  ## Upstart
8
4
 
9
5
  See `/tools/jungle/upstart` for Ubuntu's upstart scripts.
@@ -11,3 +7,13 @@ See `/tools/jungle/upstart` for Ubuntu's upstart scripts.
11
7
  ## Systemd
12
8
 
13
9
  See [/docs/systemd](https://github.com/puma/puma/blob/master/docs/systemd.md).
10
+
11
+ ## Init.d
12
+
13
+ Deprecatation Warning : `init.d` was replaced by `systemd` since Debian 8 and Ubuntu 16.04, you should look into [/docs/systemd](https://github.com/puma/puma/blob/master/docs/systemd.md) unless you are on an older OS.
14
+
15
+ See `/tools/jungle/init.d` for tools to use with init.d and start-stop-daemon.
16
+
17
+ ## rc.d
18
+
19
+ See `/tools/jungle/rc.d` for FreeBSD's rc.d scripts
@@ -1,5 +1,7 @@
1
1
  # Puma daemon service
2
2
 
3
+ Deprecatation Warning : `init.d` was replaced by `systemd` since Debian 8 and Ubuntu 16.04, you should look into [/docs/systemd](https://github.com/puma/puma/blob/master/docs/systemd.md) unless you are on an older OS.
4
+
3
5
  Init script to manage multiple Puma servers on the same box using start-stop-daemon.
4
6
 
5
7
  ## Installation
@@ -48,7 +48,7 @@ do_start_one() {
48
48
  if [ -e $PIDFILE ]; then
49
49
  PID=`cat $PIDFILE`
50
50
  # If the puma isn't running, run it, otherwise restart it.
51
- if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
51
+ if ps -p $PID > /dev/null; then
52
52
  do_start_one_do $1
53
53
  else
54
54
  do_restart_one $1
@@ -105,7 +105,7 @@ do_stop_one() {
105
105
  STATEFILE=$1/tmp/puma/state
106
106
  if [ -e $PIDFILE ]; then
107
107
  PID=`cat $PIDFILE`
108
- if [ "`ps -A -o pid= | grep -c $PID`" -eq 0 ]; then
108
+ if ps -p $PID > /dev/null; then
109
109
  log_daemon_msg "---> Puma $1 isn't running."
110
110
  else
111
111
  log_daemon_msg "---> About to kill PID `cat $PIDFILE`"
@@ -15,4 +15,4 @@ elif [ -f "$HOME/.rvm/scripts/rvm" ]; then
15
15
  fi
16
16
 
17
17
  app=$1; config=$2; log=$3;
18
- cd $app && exec bundle exec puma -C $config 2>&1 >> $log
18
+ cd $app && exec bundle exec puma -C $config >> $log 2>&1
@@ -0,0 +1,74 @@
1
+ # Puma as a service using rc.d
2
+
3
+ Manage multilpe Puma servers as services on one box using FreeBSD's rc.d service.
4
+
5
+ ## Dependencies
6
+
7
+ * `jq` - a command-line json parser is needed to parse the json in the config file
8
+
9
+ ## Installation
10
+
11
+ # Copy the puma script to the rc.d directory (make sure everyone has read/execute perms)
12
+ sudo cp puma /usr/local/etc/rc.d/
13
+
14
+ # Create an empty configuration file
15
+ sudo touch /usr/local/etc/puma.conf
16
+
17
+ # Enable the puma service
18
+ sudo echo 'puma_enable="YES"' >> /etc/rc.conf
19
+
20
+ ## Managing the jungle
21
+
22
+ Puma apps are referenced in /usr/local/etc/puma.conf by default.
23
+
24
+ Start the jungle running:
25
+
26
+ `service puma start`
27
+
28
+ This script will run at boot time.
29
+
30
+
31
+ You can also stop the jungle (stops ALL puma instances) by running:
32
+
33
+ `service puma stop`
34
+
35
+
36
+ To restart the jungle:
37
+
38
+ `service puma restart`
39
+
40
+ ## Conventions
41
+
42
+ * The script expects:
43
+ * a config file to exist under `config/puma.rb` in your app. E.g.: `/home/apps/my-app/config/puma.rb`.
44
+
45
+ You can always change those defaults by editing the scripts.
46
+
47
+ ## Here's what a minimal app's config file should have
48
+
49
+ ```
50
+ {
51
+ "servers" : [
52
+ {
53
+ "dir": "/path/to/rails/project",
54
+ "user": "deploy-user",
55
+ "ruby_version": "ruby.version",
56
+ "ruby_env": "rbenv"
57
+ }
58
+ ]
59
+ }
60
+ ```
61
+
62
+ ## Before starting...
63
+
64
+ You need to customise `puma.conf` to:
65
+
66
+ * Set the right user your app should be running on unless you want root to execute it!
67
+ * Set the directory of the app
68
+ * Set the ruby version to execute
69
+ * Set the ruby environment (currently set to rbenv, since that is the only ruby environment currently supported)
70
+ * Add additional server instances following the scheme in the example
71
+
72
+ ## Notes:
73
+
74
+ Only rbenv is currently supported.
@@ -0,0 +1,61 @@
1
+ #!/bin/sh
2
+ #
3
+
4
+ # PROVIDE: puma
5
+
6
+ . /etc/rc.subr
7
+
8
+ name="puma"
9
+ start_cmd="puma_start"
10
+ stop_cmd="puma_stop"
11
+ restart_cmd="puma_restart"
12
+ rcvar=puma_enable
13
+ required_files=/usr/local/etc/puma.conf
14
+
15
+ puma_start()
16
+ {
17
+ server_count=$(/usr/local/bin/jq ".servers[] .ruby_env" /usr/local/etc/puma.conf | wc -l)
18
+ i=0
19
+ while [ "$i" -lt "$server_count" ]; do
20
+ rb_env=$(/usr/local/bin/jq -r ".servers[$i].ruby_env" /usr/local/etc/puma.conf)
21
+ dir=$(/usr/local/bin/jq -r ".servers[$i].dir" /usr/local/etc/puma.conf)
22
+ user=$(/usr/local/bin/jq -r ".servers[$i].user" /usr/local/etc/puma.conf)
23
+ rb_ver=$(/usr/local/bin/jq -r ".servers[$i].ruby_version" /usr/local/etc/puma.conf)
24
+ case $rb_env in
25
+ "rbenv")
26
+ su - $user -c "cd $dir && rbenv shell $rb_ver && bundle exec puma -C $dir/config/puma.rb -d"
27
+ ;;
28
+ *)
29
+ ;;
30
+ esac
31
+ i=$(( i + 1 ))
32
+ done
33
+ }
34
+
35
+ puma_stop()
36
+ {
37
+ pkill ruby
38
+ }
39
+
40
+ puma_restart()
41
+ {
42
+ server_count=$(/usr/local/bin/jq ".servers[] .ruby_env" /usr/local/etc/puma.conf | wc -l)
43
+ i=0
44
+ while [ "$i" -lt "$server_count" ]; do
45
+ rb_env=$(/usr/local/bin/jq -r ".servers[$i].ruby_env" /usr/local/etc/puma.conf)
46
+ dir=$(/usr/local/bin/jq -r ".servers[$i].dir" /usr/local/etc/puma.conf)
47
+ user=$(/usr/local/bin/jq -r ".servers[$i].user" /usr/local/etc/puma.conf)
48
+ rb_ver=$(/usr/local/bin/jq -r ".servers[$i].ruby_version" /usr/local/etc/puma.conf)
49
+ case $rb_env in
50
+ "rbenv")
51
+ su - $user -c "cd $dir && pkill ruby && rbenv shell $ruby_version && bundle exec puma -C $dir/config/puma.rb -d"
52
+ ;;
53
+ *)
54
+ ;;
55
+ esac
56
+ i=$(( i + 1 ))
57
+ done
58
+ }
59
+
60
+ load_rc_config $name
61
+ run_rc_command "$1"
@@ -0,0 +1,10 @@
1
+ {
2
+ "servers" : [
3
+ {
4
+ "dir": "/path/to/rails/project",
5
+ "user": "deploy-user",
6
+ "ruby_version": "ruby.version",
7
+ "ruby_env": "rbenv"
8
+ }
9
+ ]
10
+ }
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.11.3
4
+ version: 3.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Phoenix
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-06 00:00:00.000000000 Z
11
+ date: 2018-04-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server
14
14
  for Ruby/Rack applications. Puma is intended for use in both development and production
@@ -96,6 +96,9 @@ files:
96
96
  - tools/jungle/init.d/README.md
97
97
  - tools/jungle/init.d/puma
98
98
  - tools/jungle/init.d/run-puma
99
+ - tools/jungle/rc.d/README.md
100
+ - tools/jungle/rc.d/puma
101
+ - tools/jungle/rc.d/puma.conf
99
102
  - tools/jungle/upstart/README.md
100
103
  - tools/jungle/upstart/puma-manager.conf
101
104
  - tools/jungle/upstart/puma.conf
@@ -121,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
124
  version: '0'
122
125
  requirements: []
123
126
  rubyforge_project:
124
- rubygems_version: 2.6.14
127
+ rubygems_version: 2.7.6
125
128
  signing_key:
126
129
  specification_version: 4
127
130
  summary: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for