puma 3.11.3 → 4.0.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.

Files changed (54) hide show
  1. checksums.yaml +5 -5
  2. data/History.md +61 -0
  3. data/README.md +41 -11
  4. data/docs/architecture.md +2 -1
  5. data/docs/deployment.md +24 -4
  6. data/docs/restart.md +5 -3
  7. data/docs/systemd.md +37 -9
  8. data/ext/puma_http11/PumaHttp11Service.java +2 -0
  9. data/ext/puma_http11/mini_ssl.c +42 -5
  10. data/ext/puma_http11/org/jruby/puma/IOBuffer.java +72 -0
  11. data/ext/puma_http11/org/jruby/puma/MiniSSL.java +17 -4
  12. data/lib/puma.rb +8 -0
  13. data/lib/puma/app/status.rb +3 -2
  14. data/lib/puma/binder.rb +22 -10
  15. data/lib/puma/cli.rb +18 -7
  16. data/lib/puma/client.rb +54 -22
  17. data/lib/puma/cluster.rb +54 -15
  18. data/lib/puma/commonlogger.rb +2 -0
  19. data/lib/puma/configuration.rb +4 -1
  20. data/lib/puma/const.rb +8 -2
  21. data/lib/puma/control_cli.rb +23 -11
  22. data/lib/puma/convenient.rb +2 -0
  23. data/lib/puma/daemon_ext.rb +2 -0
  24. data/lib/puma/delegation.rb +2 -0
  25. data/lib/puma/detect.rb +2 -0
  26. data/lib/puma/dsl.rb +63 -11
  27. data/lib/puma/events.rb +2 -0
  28. data/lib/puma/io_buffer.rb +3 -6
  29. data/lib/puma/jruby_restart.rb +2 -0
  30. data/lib/puma/launcher.rb +15 -13
  31. data/lib/puma/minissl.rb +20 -4
  32. data/lib/puma/null_io.rb +2 -0
  33. data/lib/puma/plugin.rb +2 -0
  34. data/lib/puma/rack/builder.rb +2 -1
  35. data/lib/puma/reactor.rb +215 -30
  36. data/lib/puma/runner.rb +11 -2
  37. data/lib/puma/server.rb +63 -26
  38. data/lib/puma/single.rb +14 -3
  39. data/lib/puma/state_file.rb +2 -0
  40. data/lib/puma/tcp_logger.rb +2 -0
  41. data/lib/puma/thread_pool.rb +50 -5
  42. data/lib/puma/util.rb +2 -6
  43. data/lib/rack/handler/puma.rb +4 -0
  44. data/tools/jungle/README.md +10 -4
  45. data/tools/jungle/init.d/README.md +2 -0
  46. data/tools/jungle/init.d/puma +7 -7
  47. data/tools/jungle/init.d/run-puma +1 -1
  48. data/tools/jungle/rc.d/README.md +74 -0
  49. data/tools/jungle/rc.d/puma +61 -0
  50. data/tools/jungle/rc.d/puma.conf +10 -0
  51. metadata +23 -9
  52. data/lib/puma/compat.rb +0 -14
  53. data/lib/puma/java_io_buffer.rb +0 -45
  54. data/lib/puma/rack/backports/uri/common_193.rb +0 -33
@@ -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,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.11.3
4
+ version: 4.0.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: 2018-03-06 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2019-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nio4r
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
13
27
  description: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server
14
28
  for Ruby/Rack applications. Puma is intended for use in both development and production
15
29
  environments. It's great for highly concurrent Ruby implementations such as Rubinius
@@ -51,6 +65,7 @@ files:
51
65
  - ext/puma_http11/mini_ssl.c
52
66
  - ext/puma_http11/org/jruby/puma/Http11.java
53
67
  - ext/puma_http11/org/jruby/puma/Http11Parser.java
68
+ - ext/puma_http11/org/jruby/puma/IOBuffer.java
54
69
  - ext/puma_http11/org/jruby/puma/MiniSSL.java
55
70
  - ext/puma_http11/puma_http11.c
56
71
  - lib/puma.rb
@@ -61,7 +76,6 @@ files:
61
76
  - lib/puma/client.rb
62
77
  - lib/puma/cluster.rb
63
78
  - lib/puma/commonlogger.rb
64
- - lib/puma/compat.rb
65
79
  - lib/puma/configuration.rb
66
80
  - lib/puma/const.rb
67
81
  - lib/puma/control_cli.rb
@@ -72,14 +86,12 @@ files:
72
86
  - lib/puma/dsl.rb
73
87
  - lib/puma/events.rb
74
88
  - lib/puma/io_buffer.rb
75
- - lib/puma/java_io_buffer.rb
76
89
  - lib/puma/jruby_restart.rb
77
90
  - lib/puma/launcher.rb
78
91
  - lib/puma/minissl.rb
79
92
  - lib/puma/null_io.rb
80
93
  - lib/puma/plugin.rb
81
94
  - lib/puma/plugin/tmp_restart.rb
82
- - lib/puma/rack/backports/uri/common_193.rb
83
95
  - lib/puma/rack/builder.rb
84
96
  - lib/puma/rack/urlmap.rb
85
97
  - lib/puma/rack_default.rb
@@ -96,6 +108,9 @@ files:
96
108
  - tools/jungle/init.d/README.md
97
109
  - tools/jungle/init.d/puma
98
110
  - tools/jungle/init.d/run-puma
111
+ - tools/jungle/rc.d/README.md
112
+ - tools/jungle/rc.d/puma
113
+ - tools/jungle/rc.d/puma.conf
99
114
  - tools/jungle/upstart/README.md
100
115
  - tools/jungle/upstart/puma-manager.conf
101
116
  - tools/jungle/upstart/puma.conf
@@ -113,15 +128,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
128
  requirements:
114
129
  - - ">="
115
130
  - !ruby/object:Gem::Version
116
- version: 1.9.3
131
+ version: '2.2'
117
132
  required_rubygems_version: !ruby/object:Gem::Requirement
118
133
  requirements:
119
134
  - - ">="
120
135
  - !ruby/object:Gem::Version
121
136
  version: '0'
122
137
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.6.14
138
+ rubygems_version: 3.0.3
125
139
  signing_key:
126
140
  specification_version: 4
127
141
  summary: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for
data/lib/puma/compat.rb DELETED
@@ -1,14 +0,0 @@
1
- # Provides code to work properly on 1.8 and 1.9
2
-
3
- class String
4
- unless method_defined? :bytesize
5
- alias_method :bytesize, :size
6
- end
7
-
8
- unless method_defined? :byteslice
9
- def byteslice(*arg)
10
- enc = self.encoding
11
- self.dup.force_encoding(Encoding::ASCII_8BIT).slice(*arg).force_encoding(enc)
12
- end
13
- end
14
- end
@@ -1,45 +0,0 @@
1
- require 'java'
2
-
3
- # Conservative native JRuby/Java implementation of IOBuffer
4
- # backed by a ByteArrayOutputStream and conversion between
5
- # Ruby String and Java bytes
6
- module Puma
7
- class JavaIOBuffer < java.io.ByteArrayOutputStream
8
- field_reader :buf
9
- end
10
-
11
- class IOBuffer
12
- BUF_DEFAULT_SIZE = 4096
13
-
14
- def initialize
15
- @buf = JavaIOBuffer.new(BUF_DEFAULT_SIZE)
16
- end
17
-
18
- def reset
19
- @buf.reset
20
- end
21
-
22
- def <<(str)
23
- bytes = str.to_java_bytes
24
- @buf.write(bytes, 0, bytes.length)
25
- end
26
-
27
- def append(*strs)
28
- strs.each { |s| self << s; }
29
- end
30
-
31
- def to_s
32
- String.from_java_bytes @buf.to_byte_array
33
- end
34
-
35
- alias_method :to_str, :to_s
36
-
37
- def used
38
- @buf.size
39
- end
40
-
41
- def capacity
42
- @buf.buf.length
43
- end
44
- end
45
- end
@@ -1,33 +0,0 @@
1
- # :stopdoc:
2
-
3
- require 'uri/common'
4
-
5
- # Issue:
6
- # http://bugs.ruby-lang.org/issues/5925
7
- #
8
- # Relevant commit:
9
- # https://github.com/ruby/ruby/commit/edb7cdf1eabaff78dfa5ffedfbc2e91b29fa9ca1
10
-
11
-
12
- module URI
13
- begin
14
- 256.times do |i|
15
- TBLENCWWWCOMP_[i.chr] = '%%%02X' % i
16
- end
17
- TBLENCWWWCOMP_[' '] = '+'
18
- TBLENCWWWCOMP_.freeze
19
-
20
- 256.times do |i|
21
- h, l = i>>4, i&15
22
- TBLDECWWWCOMP_['%%%X%X' % [h, l]] = i.chr
23
- TBLDECWWWCOMP_['%%%x%X' % [h, l]] = i.chr
24
- TBLDECWWWCOMP_['%%%X%x' % [h, l]] = i.chr
25
- TBLDECWWWCOMP_['%%%x%x' % [h, l]] = i.chr
26
- end
27
- TBLDECWWWCOMP_['+'] = ' '
28
- TBLDECWWWCOMP_.freeze
29
- rescue Exception
30
- end
31
- end
32
-
33
- # :startdoc: