puma 3.12.6 → 6.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 +4 -4
- data/History.md +1806 -451
- data/LICENSE +23 -20
- data/README.md +217 -65
- data/bin/puma-wild +3 -9
- data/docs/architecture.md +59 -21
- data/docs/compile_options.md +55 -0
- data/docs/deployment.md +69 -58
- data/docs/fork_worker.md +31 -0
- data/docs/images/puma-connection-flow-no-reactor.png +0 -0
- data/docs/images/puma-connection-flow.png +0 -0
- data/docs/images/puma-general-arch.png +0 -0
- data/docs/jungle/README.md +9 -0
- data/{tools → docs}/jungle/rc.d/README.md +1 -1
- data/{tools → docs}/jungle/rc.d/puma +2 -2
- data/docs/kubernetes.md +66 -0
- data/docs/nginx.md +2 -2
- data/docs/plugins.md +22 -12
- data/docs/rails_dev_mode.md +28 -0
- data/docs/restart.md +47 -22
- data/docs/signals.md +13 -11
- data/docs/stats.md +142 -0
- data/docs/systemd.md +94 -120
- data/docs/testing_benchmarks_local_files.md +150 -0
- data/docs/testing_test_rackup_ci_files.md +36 -0
- data/ext/puma_http11/PumaHttp11Service.java +2 -2
- data/ext/puma_http11/ext_help.h +1 -1
- data/ext/puma_http11/extconf.rb +61 -3
- data/ext/puma_http11/http11_parser.c +103 -117
- data/ext/puma_http11/http11_parser.h +2 -2
- data/ext/puma_http11/http11_parser.java.rl +22 -38
- data/ext/puma_http11/http11_parser.rl +3 -3
- data/ext/puma_http11/http11_parser_common.rl +6 -6
- data/ext/puma_http11/mini_ssl.c +389 -99
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/Http11.java +108 -116
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +84 -99
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +248 -92
- data/ext/puma_http11/puma_http11.c +49 -57
- data/lib/puma/app/status.rb +71 -49
- data/lib/puma/binder.rb +244 -150
- data/lib/puma/cli.rb +38 -34
- data/lib/puma/client.rb +388 -244
- data/lib/puma/cluster/worker.rb +180 -0
- data/lib/puma/cluster/worker_handle.rb +97 -0
- data/lib/puma/cluster.rb +261 -243
- data/lib/puma/commonlogger.rb +21 -14
- data/lib/puma/configuration.rb +116 -88
- data/lib/puma/const.rb +154 -104
- data/lib/puma/control_cli.rb +115 -70
- data/lib/puma/detect.rb +33 -2
- data/lib/puma/dsl.rb +764 -134
- data/lib/puma/error_logger.rb +113 -0
- data/lib/puma/events.rb +16 -112
- data/lib/puma/io_buffer.rb +42 -5
- data/lib/puma/jruby_restart.rb +2 -59
- data/lib/puma/json_serialization.rb +96 -0
- data/lib/puma/launcher/bundle_pruner.rb +104 -0
- data/lib/puma/launcher.rb +184 -133
- data/lib/puma/log_writer.rb +147 -0
- data/lib/puma/minissl/context_builder.rb +93 -0
- data/lib/puma/minissl.rb +263 -70
- data/lib/puma/null_io.rb +18 -1
- data/lib/puma/plugin/systemd.rb +90 -0
- data/lib/puma/plugin/tmp_restart.rb +3 -1
- data/lib/puma/plugin.rb +7 -13
- data/lib/puma/rack/builder.rb +9 -11
- data/lib/puma/rack/urlmap.rb +2 -0
- data/lib/puma/rack_default.rb +21 -4
- data/lib/puma/reactor.rb +93 -315
- data/lib/puma/request.rb +671 -0
- data/lib/puma/runner.rb +94 -69
- data/lib/puma/sd_notify.rb +149 -0
- data/lib/puma/server.rb +327 -772
- data/lib/puma/single.rb +20 -74
- data/lib/puma/state_file.rb +45 -8
- data/lib/puma/thread_pool.rb +146 -92
- data/lib/puma/util.rb +22 -10
- data/lib/puma.rb +60 -5
- data/lib/rack/handler/puma.rb +116 -90
- data/tools/Dockerfile +16 -0
- data/tools/trickletest.rb +0 -1
- metadata +54 -32
- data/ext/puma_http11/io_buffer.c +0 -155
- data/lib/puma/accept_nonblock.rb +0 -23
- data/lib/puma/compat.rb +0 -14
- data/lib/puma/convenient.rb +0 -25
- data/lib/puma/daemon_ext.rb +0 -33
- data/lib/puma/delegation.rb +0 -13
- data/lib/puma/java_io_buffer.rb +0 -47
- data/lib/puma/rack/backports/uri/common_193.rb +0 -33
- data/lib/puma/tcp_logger.rb +0 -41
- data/tools/jungle/README.md +0 -19
- data/tools/jungle/init.d/README.md +0 -61
- data/tools/jungle/init.d/puma +0 -421
- data/tools/jungle/init.d/run-puma +0 -18
- data/tools/jungle/upstart/README.md +0 -61
- data/tools/jungle/upstart/puma-manager.conf +0 -31
- data/tools/jungle/upstart/puma.conf +0 -69
- /data/{tools → docs}/jungle/rc.d/puma.conf +0 -0
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
|
data/lib/puma/convenient.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'puma/launcher'
|
4
|
-
require 'puma/configuration'
|
5
|
-
|
6
|
-
module Puma
|
7
|
-
def self.run(opts={})
|
8
|
-
cfg = Puma::Configuration.new do |user_config|
|
9
|
-
if port = opts[:port]
|
10
|
-
user_config.port port
|
11
|
-
end
|
12
|
-
|
13
|
-
user_config.quiet
|
14
|
-
|
15
|
-
yield c
|
16
|
-
end
|
17
|
-
|
18
|
-
cfg.clamp
|
19
|
-
|
20
|
-
events = Puma::Events.null
|
21
|
-
|
22
|
-
launcher = Puma::Launcher.new cfg, :events => events
|
23
|
-
launcher.run
|
24
|
-
end
|
25
|
-
end
|
data/lib/puma/daemon_ext.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Process
|
4
|
-
|
5
|
-
# This overrides the default version because it is broken if it
|
6
|
-
# exists.
|
7
|
-
|
8
|
-
if respond_to? :daemon
|
9
|
-
class << self
|
10
|
-
remove_method :daemon
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.daemon(nochdir=false, noclose=false)
|
15
|
-
exit if fork # Parent exits, child continues.
|
16
|
-
|
17
|
-
Process.setsid # Become session leader.
|
18
|
-
|
19
|
-
exit if fork # Zap session leader. See [1].
|
20
|
-
|
21
|
-
Dir.chdir "/" unless nochdir # Release old working directory.
|
22
|
-
|
23
|
-
if !noclose
|
24
|
-
STDIN.reopen File.open("/dev/null", "r")
|
25
|
-
|
26
|
-
null_out = File.open "/dev/null", "w"
|
27
|
-
STDOUT.reopen null_out
|
28
|
-
STDERR.reopen null_out
|
29
|
-
end
|
30
|
-
|
31
|
-
0
|
32
|
-
end
|
33
|
-
end
|
data/lib/puma/delegation.rb
DELETED
data/lib/puma/java_io_buffer.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'java'
|
4
|
-
|
5
|
-
# Conservative native JRuby/Java implementation of IOBuffer
|
6
|
-
# backed by a ByteArrayOutputStream and conversion between
|
7
|
-
# Ruby String and Java bytes
|
8
|
-
module Puma
|
9
|
-
class JavaIOBuffer < java.io.ByteArrayOutputStream
|
10
|
-
field_reader :buf
|
11
|
-
end
|
12
|
-
|
13
|
-
class IOBuffer
|
14
|
-
BUF_DEFAULT_SIZE = 4096
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@buf = JavaIOBuffer.new(BUF_DEFAULT_SIZE)
|
18
|
-
end
|
19
|
-
|
20
|
-
def reset
|
21
|
-
@buf.reset
|
22
|
-
end
|
23
|
-
|
24
|
-
def <<(str)
|
25
|
-
bytes = str.to_java_bytes
|
26
|
-
@buf.write(bytes, 0, bytes.length)
|
27
|
-
end
|
28
|
-
|
29
|
-
def append(*strs)
|
30
|
-
strs.each { |s| self << s; }
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_s
|
34
|
-
String.from_java_bytes @buf.to_byte_array
|
35
|
-
end
|
36
|
-
|
37
|
-
alias_method :to_str, :to_s
|
38
|
-
|
39
|
-
def used
|
40
|
-
@buf.size
|
41
|
-
end
|
42
|
-
|
43
|
-
def capacity
|
44
|
-
@buf.buf.length
|
45
|
-
end
|
46
|
-
end
|
47
|
-
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:
|
data/lib/puma/tcp_logger.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Puma
|
4
|
-
class TCPLogger
|
5
|
-
def initialize(logger, app, quiet=false)
|
6
|
-
@logger = logger
|
7
|
-
@app = app
|
8
|
-
@quiet = quiet
|
9
|
-
end
|
10
|
-
|
11
|
-
FORMAT = "%s - %s"
|
12
|
-
|
13
|
-
def log(who, str)
|
14
|
-
now = Time.now.strftime("%d/%b/%Y %H:%M:%S")
|
15
|
-
|
16
|
-
log_str = "#{now} - #{who} - #{str}"
|
17
|
-
|
18
|
-
case @logger
|
19
|
-
when IO
|
20
|
-
@logger.puts log_str
|
21
|
-
when Events
|
22
|
-
@logger.log log_str
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def call(env, socket)
|
27
|
-
who = env[Const::REMOTE_ADDR]
|
28
|
-
log who, "connected" unless @quiet
|
29
|
-
|
30
|
-
env['log'] = lambda { |str| log(who, str) }
|
31
|
-
|
32
|
-
begin
|
33
|
-
@app.call env, socket
|
34
|
-
rescue Object => e
|
35
|
-
log who, "exception: #{e.message} (#{e.class})"
|
36
|
-
else
|
37
|
-
log who, "disconnected" unless @quiet
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/tools/jungle/README.md
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
# Puma as a service
|
2
|
-
|
3
|
-
## Upstart
|
4
|
-
|
5
|
-
See `/tools/jungle/upstart` for Ubuntu's upstart scripts.
|
6
|
-
|
7
|
-
## Systemd
|
8
|
-
|
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,61 +0,0 @@
|
|
1
|
-
# Puma daemon service
|
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
|
-
|
5
|
-
Init script to manage multiple Puma servers on the same box using start-stop-daemon.
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
# Copy the init script to services directory
|
10
|
-
sudo cp puma /etc/init.d
|
11
|
-
sudo chmod +x /etc/init.d/puma
|
12
|
-
|
13
|
-
# Make it start at boot time.
|
14
|
-
sudo update-rc.d -f puma defaults
|
15
|
-
|
16
|
-
# Copy the Puma runner to an accessible location
|
17
|
-
sudo cp run-puma /usr/local/bin
|
18
|
-
sudo chmod +x /usr/local/bin/run-puma
|
19
|
-
|
20
|
-
# Create an empty configuration file
|
21
|
-
sudo touch /etc/puma.conf
|
22
|
-
|
23
|
-
## Managing the jungle
|
24
|
-
|
25
|
-
Puma apps are held in /etc/puma.conf by default. It's mainly a CSV file and every line represents one app. Here's the syntax:
|
26
|
-
|
27
|
-
app-path,user,config-file-path,log-file-path,environment-variables
|
28
|
-
|
29
|
-
You can add an instance by editing the file or running the following command:
|
30
|
-
|
31
|
-
sudo /etc/init.d/puma add /path/to/app user /path/to/app/config/puma.rb /path/to/app/log/puma.log
|
32
|
-
|
33
|
-
The config and log paths, as well as the environment variables, are optional parameters and default to:
|
34
|
-
|
35
|
-
* config: /path/to/app/*config/puma.rb*
|
36
|
-
* log: /path/to/app/*log/puma.log*
|
37
|
-
* environment: (empty)
|
38
|
-
|
39
|
-
Multiple environment variables need to be separated by a semicolon, e.g.
|
40
|
-
|
41
|
-
FOO=1;BAR=2
|
42
|
-
|
43
|
-
To remove an app, simply delete the line from the config file or run:
|
44
|
-
|
45
|
-
sudo /etc/init.d/puma remove /path/to/app
|
46
|
-
|
47
|
-
The command will make sure the Puma instance stops before removing it from the jungle.
|
48
|
-
|
49
|
-
## Assumptions
|
50
|
-
|
51
|
-
* The script expects a temporary folder named /path/to/app/*tmp/puma* to exist. Create it if it's not there by default.
|
52
|
-
The pid and state files should live there and must be called: *tmp/puma/pid* and *tmp/puma/state*.
|
53
|
-
You can change those if you want but you'll have to adapt the script for it to work.
|
54
|
-
|
55
|
-
* Here's what a minimal app's config file should have:
|
56
|
-
|
57
|
-
```
|
58
|
-
pidfile "/path/to/app/tmp/puma/pid"
|
59
|
-
state_path "/path/to/app/tmp/puma/state"
|
60
|
-
activate_control_app
|
61
|
-
```
|