puma 2.1.1 → 7.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/History.md +3273 -0
- data/LICENSE +23 -20
- data/README.md +388 -100
- data/bin/puma-wild +25 -0
- data/bin/pumactl +1 -1
- data/docs/architecture.md +74 -0
- data/docs/compile_options.md +55 -0
- data/docs/deployment.md +137 -0
- data/docs/fork_worker.md +41 -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/java_options.md +54 -0
- data/docs/jungle/README.md +9 -0
- data/docs/jungle/rc.d/README.md +74 -0
- data/docs/jungle/rc.d/puma +61 -0
- data/docs/jungle/rc.d/puma.conf +10 -0
- data/docs/kubernetes.md +73 -0
- data/docs/nginx.md +5 -5
- data/docs/plugins.md +42 -0
- data/docs/rails_dev_mode.md +28 -0
- data/docs/restart.md +65 -0
- data/docs/signals.md +98 -0
- data/docs/stats.md +148 -0
- data/docs/systemd.md +253 -0
- 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/extconf.rb +59 -2
- data/ext/puma_http11/http11_parser.c +319 -487
- data/ext/puma_http11/http11_parser.h +15 -13
- data/ext/puma_http11/http11_parser.java.rl +27 -43
- data/ext/puma_http11/http11_parser.rl +27 -24
- data/ext/puma_http11/http11_parser_common.rl +8 -8
- data/ext/puma_http11/mini_ssl.c +696 -38
- data/ext/puma_http11/no_ssl/PumaHttp11Service.java +15 -0
- data/ext/puma_http11/org/jruby/puma/Http11.java +145 -113
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +139 -172
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +413 -193
- data/ext/puma_http11/puma_http11.c +183 -175
- data/lib/puma/app/status.rb +77 -29
- data/lib/puma/binder.rb +349 -119
- data/lib/puma/cli.rb +164 -769
- data/lib/puma/client.rb +591 -132
- data/lib/puma/cluster/worker.rb +183 -0
- data/lib/puma/cluster/worker_handle.rb +127 -0
- data/lib/puma/cluster.rb +634 -0
- data/lib/puma/cluster_accept_loop_delay.rb +91 -0
- data/lib/puma/commonlogger.rb +115 -0
- data/lib/puma/configuration.rb +370 -202
- data/lib/puma/const.rb +266 -115
- data/lib/puma/control_cli.rb +219 -120
- data/lib/puma/detect.rb +45 -2
- data/lib/puma/dsl.rb +1496 -0
- data/lib/puma/error_logger.rb +115 -0
- data/lib/puma/events.rb +44 -60
- data/lib/puma/io_buffer.rb +48 -5
- data/lib/puma/jruby_restart.rb +2 -51
- data/lib/puma/json_serialization.rb +96 -0
- data/lib/puma/launcher/bundle_pruner.rb +104 -0
- data/lib/puma/launcher.rb +502 -0
- data/lib/puma/log_writer.rb +147 -0
- data/lib/puma/minissl/context_builder.rb +96 -0
- data/lib/puma/minissl.rb +355 -37
- data/lib/puma/null_io.rb +79 -12
- data/lib/puma/plugin/systemd.rb +90 -0
- data/lib/puma/plugin/tmp_restart.rb +36 -0
- data/lib/puma/plugin.rb +111 -0
- data/lib/puma/rack/builder.rb +297 -0
- data/lib/puma/rack/urlmap.rb +93 -0
- data/lib/puma/rack_default.rb +21 -4
- data/lib/puma/reactor.rb +102 -133
- data/lib/puma/request.rb +703 -0
- data/lib/puma/runner.rb +211 -0
- data/lib/puma/sd_notify.rb +146 -0
- data/lib/puma/server.rb +544 -436
- data/lib/puma/single.rb +72 -0
- data/lib/puma/state_file.rb +69 -0
- data/lib/puma/thread_pool.rb +282 -56
- data/lib/puma/util.rb +125 -0
- data/lib/puma.rb +80 -6
- data/lib/rack/handler/puma.rb +125 -47
- data/tools/Dockerfile +26 -0
- data/tools/trickletest.rb +44 -0
- metadata +77 -148
- data/COPYING +0 -55
- data/Gemfile +0 -10
- data/History.txt +0 -291
- data/Manifest.txt +0 -60
- data/Rakefile +0 -121
- data/TODO +0 -5
- data/docs/config.md +0 -0
- data/ext/puma_http11/ext_help.h +0 -15
- data/ext/puma_http11/io_buffer.c +0 -154
- data/lib/puma/accept_nonblock.rb +0 -23
- data/lib/puma/capistrano.rb +0 -34
- data/lib/puma/compat.rb +0 -11
- data/lib/puma/daemon_ext.rb +0 -20
- data/lib/puma/delegation.rb +0 -11
- data/lib/puma/java_io_buffer.rb +0 -45
- data/lib/puma/rack_patch.rb +0 -25
- data/puma.gemspec +0 -45
- data/test/test_app_status.rb +0 -88
- data/test/test_cli.rb +0 -171
- data/test/test_config.rb +0 -16
- data/test/test_http10.rb +0 -27
- data/test/test_http11.rb +0 -126
- data/test/test_integration.rb +0 -154
- data/test/test_iobuffer.rb +0 -38
- data/test/test_minissl.rb +0 -25
- data/test/test_null_io.rb +0 -31
- data/test/test_persistent.rb +0 -238
- data/test/test_puma_server.rb +0 -207
- data/test/test_rack_handler.rb +0 -10
- data/test/test_rack_server.rb +0 -141
- data/test/test_thread_pool.rb +0 -146
- data/test/test_unix_socket.rb +0 -39
- data/test/test_ws.rb +0 -89
- data/tools/jungle/init.d/README.md +0 -54
- data/tools/jungle/init.d/puma +0 -332
- data/tools/jungle/init.d/run-puma +0 -3
- data/tools/jungle/upstart/README.md +0 -61
- data/tools/jungle/upstart/puma-manager.conf +0 -31
- data/tools/jungle/upstart/puma.conf +0 -52
data/Manifest.txt
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
COPYING
|
|
2
|
-
Gemfile
|
|
3
|
-
History.txt
|
|
4
|
-
LICENSE
|
|
5
|
-
Manifest.txt
|
|
6
|
-
README.md
|
|
7
|
-
Rakefile
|
|
8
|
-
TODO
|
|
9
|
-
bin/puma
|
|
10
|
-
bin/pumactl
|
|
11
|
-
docs/config.md
|
|
12
|
-
docs/nginx.md
|
|
13
|
-
ext/puma_http11/PumaHttp11Service.java
|
|
14
|
-
ext/puma_http11/ext_help.h
|
|
15
|
-
ext/puma_http11/extconf.rb
|
|
16
|
-
ext/puma_http11/http11_parser.c
|
|
17
|
-
ext/puma_http11/http11_parser.h
|
|
18
|
-
ext/puma_http11/http11_parser.java.rl
|
|
19
|
-
ext/puma_http11/http11_parser.rl
|
|
20
|
-
ext/puma_http11/http11_parser_common.rl
|
|
21
|
-
ext/puma_http11/io_buffer.c
|
|
22
|
-
ext/puma_http11/mini_ssl.c
|
|
23
|
-
ext/puma_http11/org/jruby/puma/Http11.java
|
|
24
|
-
ext/puma_http11/org/jruby/puma/Http11Parser.java
|
|
25
|
-
ext/puma_http11/org/jruby/puma/MiniSSL.java
|
|
26
|
-
ext/puma_http11/puma_http11.c
|
|
27
|
-
lib/puma.rb
|
|
28
|
-
lib/puma/accept_nonblock.rb
|
|
29
|
-
lib/puma/app/status.rb
|
|
30
|
-
lib/puma/binder.rb
|
|
31
|
-
lib/puma/capistrano.rb
|
|
32
|
-
lib/puma/cli.rb
|
|
33
|
-
lib/puma/client.rb
|
|
34
|
-
lib/puma/compat.rb
|
|
35
|
-
lib/puma/configuration.rb
|
|
36
|
-
lib/puma/const.rb
|
|
37
|
-
lib/puma/control_cli.rb
|
|
38
|
-
lib/puma/daemon_ext.rb
|
|
39
|
-
lib/puma/delegation.rb
|
|
40
|
-
lib/puma/detect.rb
|
|
41
|
-
lib/puma/events.rb
|
|
42
|
-
lib/puma/io_buffer.rb
|
|
43
|
-
lib/puma/java_io_buffer.rb
|
|
44
|
-
lib/puma/jruby_restart.rb
|
|
45
|
-
lib/puma/minissl.rb
|
|
46
|
-
lib/puma/null_io.rb
|
|
47
|
-
lib/puma/rack_default.rb
|
|
48
|
-
lib/puma/rack_patch.rb
|
|
49
|
-
lib/puma/reactor.rb
|
|
50
|
-
lib/puma/server.rb
|
|
51
|
-
lib/puma/thread_pool.rb
|
|
52
|
-
lib/puma/util.rb
|
|
53
|
-
lib/rack/handler/puma.rb
|
|
54
|
-
puma.gemspec
|
|
55
|
-
tools/jungle/init.d/README.md
|
|
56
|
-
tools/jungle/init.d/puma
|
|
57
|
-
tools/jungle/init.d/run-puma
|
|
58
|
-
tools/jungle/upstart/README.md
|
|
59
|
-
tools/jungle/upstart/puma-manager.conf
|
|
60
|
-
tools/jungle/upstart/puma.conf
|
data/Rakefile
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
require "hoe"
|
|
2
|
-
require "rake/extensiontask"
|
|
3
|
-
require "rake/javaextensiontask"
|
|
4
|
-
|
|
5
|
-
IS_JRUBY = defined?(RUBY_ENGINE) ? RUBY_ENGINE == "jruby" : false
|
|
6
|
-
|
|
7
|
-
Hoe.plugin :git
|
|
8
|
-
|
|
9
|
-
HOE = Hoe.spec "puma" do
|
|
10
|
-
self.rubyforge_name = 'puma'
|
|
11
|
-
self.readme_file = "README.md"
|
|
12
|
-
self.urls = %w!http://puma.io https://github.com/puma/puma!
|
|
13
|
-
|
|
14
|
-
developer 'Evan Phoenix', 'evan@phx.io'
|
|
15
|
-
|
|
16
|
-
spec_extras[:extensions] = ["ext/puma_http11/extconf.rb"]
|
|
17
|
-
spec_extras[:executables] = ['puma', 'pumactl']
|
|
18
|
-
spec_extras[:homepage] = self.urls.first
|
|
19
|
-
|
|
20
|
-
require_ruby_version ">= 1.8.7"
|
|
21
|
-
|
|
22
|
-
dependency "rack", [">= 1.1", "< 2.0"]
|
|
23
|
-
|
|
24
|
-
extra_dev_deps << ["rake-compiler", "~> 0.8.0"]
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
# hoe/test and rake-compiler don't seem to play well together, so disable
|
|
28
|
-
# hoe/test's .gemtest touch file thingy for now
|
|
29
|
-
HOE.spec.files -= [".gemtest"]
|
|
30
|
-
|
|
31
|
-
# puma.gemspec
|
|
32
|
-
|
|
33
|
-
file "#{HOE.spec.name}.gemspec" => ['Rakefile', "lib/puma/const.rb"] do |t|
|
|
34
|
-
puts "Generating #{t.name}"
|
|
35
|
-
File.open(t.name, 'wb') { |f| f.write HOE.spec.to_ruby }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
desc "Generate or update the standalone gemspec file for the project"
|
|
39
|
-
task :gemspec => ["#{HOE.spec.name}.gemspec"]
|
|
40
|
-
|
|
41
|
-
# generate extension code using Ragel (C and Java)
|
|
42
|
-
desc "Generate extension code (C and Java) using Ragel"
|
|
43
|
-
task :ragel
|
|
44
|
-
|
|
45
|
-
file 'ext/puma_http11/http11_parser.c' => ['ext/puma_http11/http11_parser.rl'] do |t|
|
|
46
|
-
begin
|
|
47
|
-
sh "ragel #{t.prerequisites.last} -C -G2 -I ext/puma_http11 -o #{t.name}"
|
|
48
|
-
rescue
|
|
49
|
-
fail "Could not build wrapper using Ragel (it failed or not installed?)"
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
task :ragel => ['ext/puma_http11/http11_parser.c']
|
|
53
|
-
|
|
54
|
-
file 'ext/puma_http11/org/jruby/puma/Http11Parser.java' => ['ext/puma_http11/http11_parser.java.rl'] do |t|
|
|
55
|
-
begin
|
|
56
|
-
sh "ragel #{t.prerequisites.last} -J -G2 -I ext/puma_http11 -o #{t.name}"
|
|
57
|
-
rescue
|
|
58
|
-
fail "Could not build wrapper using Ragel (it failed or not installed?)"
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
task :ragel => ['ext/puma_http11/org/jruby/puma/Http11Parser.java']
|
|
62
|
-
|
|
63
|
-
if !IS_JRUBY
|
|
64
|
-
|
|
65
|
-
# compile extensions using rake-compiler
|
|
66
|
-
# C (MRI, Rubinius)
|
|
67
|
-
Rake::ExtensionTask.new("puma_http11", HOE.spec) do |ext|
|
|
68
|
-
# place extension inside namespace
|
|
69
|
-
ext.lib_dir = "lib/puma"
|
|
70
|
-
|
|
71
|
-
ext.cross_compile = true
|
|
72
|
-
ext.cross_platform = ['i386-mswin32-60', 'i386-mingw32']
|
|
73
|
-
ext.cross_compiling do |spec|
|
|
74
|
-
# add fat-binary stub only when cross compiling
|
|
75
|
-
spec.files << "lib/puma/puma_http11.rb"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
CLEAN.include "lib/puma/{1.8,1.9}"
|
|
79
|
-
CLEAN.include "lib/puma/puma_http11.rb"
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
else
|
|
83
|
-
|
|
84
|
-
# Java (JRuby)
|
|
85
|
-
Rake::JavaExtensionTask.new("puma_http11", HOE.spec) do |ext|
|
|
86
|
-
ext.lib_dir = "lib/puma"
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# the following is a fat-binary stub that will be used when
|
|
92
|
-
# require 'puma/puma_http11' and will use either 1.8 or 1.9 version depending
|
|
93
|
-
# on RUBY_VERSION
|
|
94
|
-
file "lib/puma/puma_http11.rb" do |t|
|
|
95
|
-
File.open(t.name, "w") do |f|
|
|
96
|
-
f.puts "RUBY_VERSION =~ /(\d+.\d+)/"
|
|
97
|
-
f.puts 'require "puma/#{$1}/puma_http11"'
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
# tests require extension be compiled, but depend on the platform
|
|
102
|
-
if IS_JRUBY
|
|
103
|
-
task :test => [:java]
|
|
104
|
-
else
|
|
105
|
-
task :test => [:compile]
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
namespace :test do
|
|
109
|
-
desc "Run the integration tests"
|
|
110
|
-
task :integration do
|
|
111
|
-
sh "cd test/shell; sh run.sh"
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
desc "Run all tests"
|
|
115
|
-
if defined?(JRUBY_VERSION) and ENV['TRAVIS']
|
|
116
|
-
task :all => :test
|
|
117
|
-
else
|
|
118
|
-
task :all => [:test, "test:integration"]
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
data/TODO
DELETED
data/docs/config.md
DELETED
|
File without changes
|
data/ext/puma_http11/ext_help.h
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
#ifndef ext_help_h
|
|
2
|
-
#define ext_help_h
|
|
3
|
-
|
|
4
|
-
#define RAISE_NOT_NULL(T) if(T == NULL) rb_raise(rb_eArgError, "%s", "NULL found for " # T " when shouldn't be.");
|
|
5
|
-
#define DATA_GET(from,type,name) Data_Get_Struct(from,type,name); RAISE_NOT_NULL(name);
|
|
6
|
-
#define REQUIRE_TYPE(V, T) if(TYPE(V) != T) rb_raise(rb_eTypeError, "%s", "Wrong argument type for " # V " required " # T);
|
|
7
|
-
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
|
8
|
-
|
|
9
|
-
#ifdef DEBUG
|
|
10
|
-
#define TRACE() fprintf(stderr, "> %s:%d:%s\n", __FILE__, __LINE__, __FUNCTION__)
|
|
11
|
-
#else
|
|
12
|
-
#define TRACE()
|
|
13
|
-
#endif
|
|
14
|
-
|
|
15
|
-
#endif
|
data/ext/puma_http11/io_buffer.c
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
#include "ruby.h"
|
|
2
|
-
|
|
3
|
-
#include <sys/types.h>
|
|
4
|
-
|
|
5
|
-
struct buf_int {
|
|
6
|
-
uint8_t* top;
|
|
7
|
-
uint8_t* cur;
|
|
8
|
-
|
|
9
|
-
size_t size;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
#define BUF_DEFAULT_SIZE 4096
|
|
13
|
-
#define BUF_TOLERANCE 32
|
|
14
|
-
|
|
15
|
-
static void buf_free(struct buf_int* internal) {
|
|
16
|
-
free(internal->top);
|
|
17
|
-
free(internal);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
static VALUE buf_alloc(VALUE self) {
|
|
21
|
-
VALUE buf;
|
|
22
|
-
struct buf_int* internal;
|
|
23
|
-
|
|
24
|
-
buf = Data_Make_Struct(self, struct buf_int, 0, buf_free, internal);
|
|
25
|
-
|
|
26
|
-
internal->size = BUF_DEFAULT_SIZE;
|
|
27
|
-
internal->top = malloc(BUF_DEFAULT_SIZE);
|
|
28
|
-
internal->cur = internal->top;
|
|
29
|
-
|
|
30
|
-
return buf;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
static VALUE buf_append(VALUE self, VALUE str) {
|
|
34
|
-
struct buf_int* b;
|
|
35
|
-
size_t used, str_len, new_size;
|
|
36
|
-
|
|
37
|
-
Data_Get_Struct(self, struct buf_int, b);
|
|
38
|
-
|
|
39
|
-
used = b->cur - b->top;
|
|
40
|
-
|
|
41
|
-
StringValue(str);
|
|
42
|
-
str_len = RSTRING_LEN(str);
|
|
43
|
-
|
|
44
|
-
new_size = used + str_len;
|
|
45
|
-
|
|
46
|
-
if(new_size > b->size) {
|
|
47
|
-
size_t n = b->size + (b->size / 2);
|
|
48
|
-
uint8_t* top;
|
|
49
|
-
uint8_t* old;
|
|
50
|
-
|
|
51
|
-
new_size = (n > new_size ? n : new_size + BUF_TOLERANCE);
|
|
52
|
-
|
|
53
|
-
top = malloc(new_size);
|
|
54
|
-
old = b->top;
|
|
55
|
-
memcpy(top, old, used);
|
|
56
|
-
b->top = top;
|
|
57
|
-
b->cur = top + used;
|
|
58
|
-
b->size = new_size;
|
|
59
|
-
free(old);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
memcpy(b->cur, RSTRING_PTR(str), str_len);
|
|
63
|
-
b->cur += str_len;
|
|
64
|
-
|
|
65
|
-
return self;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
static VALUE buf_append2(int argc, VALUE* argv, VALUE self) {
|
|
69
|
-
struct buf_int* b;
|
|
70
|
-
size_t used, new_size;
|
|
71
|
-
int i;
|
|
72
|
-
VALUE str;
|
|
73
|
-
|
|
74
|
-
Data_Get_Struct(self, struct buf_int, b);
|
|
75
|
-
|
|
76
|
-
used = b->cur - b->top;
|
|
77
|
-
new_size = used;
|
|
78
|
-
|
|
79
|
-
for(i = 0; i < argc; i++) {
|
|
80
|
-
StringValue(argv[i]);
|
|
81
|
-
|
|
82
|
-
str = argv[i];
|
|
83
|
-
|
|
84
|
-
new_size += RSTRING_LEN(str);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if(new_size > b->size) {
|
|
88
|
-
size_t n = b->size + (b->size / 2);
|
|
89
|
-
uint8_t* top;
|
|
90
|
-
uint8_t* old;
|
|
91
|
-
|
|
92
|
-
new_size = (n > new_size ? n : new_size + BUF_TOLERANCE);
|
|
93
|
-
|
|
94
|
-
top = malloc(new_size);
|
|
95
|
-
old = b->top;
|
|
96
|
-
memcpy(top, old, used);
|
|
97
|
-
b->top = top;
|
|
98
|
-
b->cur = top + used;
|
|
99
|
-
b->size = new_size;
|
|
100
|
-
free(old);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
for(i = 0; i < argc; i++) {
|
|
104
|
-
long str_len;
|
|
105
|
-
str = argv[i];
|
|
106
|
-
str_len = RSTRING_LEN(str);
|
|
107
|
-
memcpy(b->cur, RSTRING_PTR(str), str_len);
|
|
108
|
-
b->cur += str_len;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return self;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
static VALUE buf_to_str(VALUE self) {
|
|
115
|
-
struct buf_int* b;
|
|
116
|
-
Data_Get_Struct(self, struct buf_int, b);
|
|
117
|
-
|
|
118
|
-
return rb_str_new(b->top, b->cur - b->top);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
static VALUE buf_used(VALUE self) {
|
|
122
|
-
struct buf_int* b;
|
|
123
|
-
Data_Get_Struct(self, struct buf_int, b);
|
|
124
|
-
|
|
125
|
-
return INT2FIX(b->cur - b->top);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
static VALUE buf_capa(VALUE self) {
|
|
129
|
-
struct buf_int* b;
|
|
130
|
-
Data_Get_Struct(self, struct buf_int, b);
|
|
131
|
-
|
|
132
|
-
return INT2FIX(b->size);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
static VALUE buf_reset(VALUE self) {
|
|
136
|
-
struct buf_int* b;
|
|
137
|
-
Data_Get_Struct(self, struct buf_int, b);
|
|
138
|
-
|
|
139
|
-
b->cur = b->top;
|
|
140
|
-
return self;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
void Init_io_buffer(VALUE puma) {
|
|
144
|
-
VALUE buf = rb_define_class_under(puma, "IOBuffer", rb_cObject);
|
|
145
|
-
|
|
146
|
-
rb_define_alloc_func(buf, buf_alloc);
|
|
147
|
-
rb_define_method(buf, "<<", buf_append, 1);
|
|
148
|
-
rb_define_method(buf, "append", buf_append2, -1);
|
|
149
|
-
rb_define_method(buf, "to_str", buf_to_str, 0);
|
|
150
|
-
rb_define_method(buf, "to_s", buf_to_str, 0);
|
|
151
|
-
rb_define_method(buf, "used", buf_used, 0);
|
|
152
|
-
rb_define_method(buf, "capacity", buf_capa, 0);
|
|
153
|
-
rb_define_method(buf, "reset", buf_reset, 0);
|
|
154
|
-
}
|
data/lib/puma/accept_nonblock.rb
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
require 'openssl'
|
|
2
|
-
|
|
3
|
-
module OpenSSL
|
|
4
|
-
module SSL
|
|
5
|
-
class SSLServer
|
|
6
|
-
unless public_method_defined? :accept_nonblock
|
|
7
|
-
def accept_nonblock
|
|
8
|
-
sock = @svr.accept_nonblock
|
|
9
|
-
|
|
10
|
-
begin
|
|
11
|
-
ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)
|
|
12
|
-
ssl.sync_close = true
|
|
13
|
-
ssl.accept if @start_immediately
|
|
14
|
-
ssl
|
|
15
|
-
rescue SSLError => ex
|
|
16
|
-
sock.close
|
|
17
|
-
raise ex
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
data/lib/puma/capistrano.rb
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
Capistrano::Configuration.instance.load do
|
|
2
|
-
after 'deploy:stop', 'puma:stop'
|
|
3
|
-
after 'deploy:start', 'puma:start'
|
|
4
|
-
after 'deploy:restart', 'puma:restart'
|
|
5
|
-
|
|
6
|
-
# Ensure the tmp/sockets directory is created by the deploy:setup task and
|
|
7
|
-
# symlinked in by the deploy:update task. This is not handled by Capistrano
|
|
8
|
-
# v2 but is fixed in v3.
|
|
9
|
-
shared_children.push('tmp/sockets')
|
|
10
|
-
|
|
11
|
-
_cset(:puma_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec puma" }
|
|
12
|
-
_cset(:pumactl_cmd) { "#{fetch(:bundle_cmd, 'bundle')} exec pumactl" }
|
|
13
|
-
_cset(:puma_state) { "#{shared_path}/sockets/puma.state" }
|
|
14
|
-
_cset(:puma_socket) { "unix://#{shared_path}/sockets/puma.sock" }
|
|
15
|
-
_cset(:puma_role) { :app }
|
|
16
|
-
|
|
17
|
-
namespace :puma do
|
|
18
|
-
desc 'Start puma'
|
|
19
|
-
task :start, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue do
|
|
20
|
-
puma_env = fetch(:rack_env, fetch(:rails_env, 'production'))
|
|
21
|
-
run "cd #{current_path} && #{fetch(:puma_cmd)} -q -d -e #{puma_env} -b '#{fetch(:puma_socket)}' -S #{fetch(:puma_state)} --control 'unix://#{shared_path}/sockets/pumactl.sock'", :pty => false
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
desc 'Stop puma'
|
|
25
|
-
task :stop, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue do
|
|
26
|
-
run "cd #{current_path} && #{fetch(:pumactl_cmd)} -S #{fetch(:puma_state)} stop"
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
desc 'Restart puma'
|
|
30
|
-
task :restart, :roles => lambda { fetch(:puma_role) }, :on_no_matching_servers => :continue do
|
|
31
|
-
run "cd #{current_path} && #{fetch(:pumactl_cmd)} -S #{fetch(:puma_state)} restart"
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
data/lib/puma/compat.rb
DELETED
data/lib/puma/daemon_ext.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
module Process
|
|
2
|
-
def self.daemon(nochdir=false, noclose=false)
|
|
3
|
-
exit if fork # Parent exits, child continues.
|
|
4
|
-
|
|
5
|
-
Process.setsid # Become session leader.
|
|
6
|
-
|
|
7
|
-
exit if fork # Zap session leader. See [1].
|
|
8
|
-
|
|
9
|
-
Dir.chdir "/" unless nochdir # Release old working directory.
|
|
10
|
-
|
|
11
|
-
if !noclose
|
|
12
|
-
null = File.open "/dev/null", "w+"
|
|
13
|
-
STDIN.reopen null
|
|
14
|
-
STDOUT.reopen null
|
|
15
|
-
STDERR.reopen null
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
0
|
|
19
|
-
end unless respond_to?(:daemon)
|
|
20
|
-
end
|
data/lib/puma/delegation.rb
DELETED
data/lib/puma/java_io_buffer.rb
DELETED
|
@@ -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
|
data/lib/puma/rack_patch.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
require 'rack/commonlogger'
|
|
2
|
-
|
|
3
|
-
module Rack
|
|
4
|
-
# Patch CommonLogger to use after_reply.
|
|
5
|
-
#
|
|
6
|
-
# Simply request this file and CommonLogger will be a bit more
|
|
7
|
-
# efficient.
|
|
8
|
-
class CommonLogger
|
|
9
|
-
remove_method :call
|
|
10
|
-
|
|
11
|
-
def call(env)
|
|
12
|
-
began_at = Time.now
|
|
13
|
-
status, header, body = @app.call(env)
|
|
14
|
-
header = Utils::HeaderHash.new(header)
|
|
15
|
-
|
|
16
|
-
if ary = env['rack.after_reply']
|
|
17
|
-
ary << lambda { log(env, status, header, began_at) }
|
|
18
|
-
else
|
|
19
|
-
body = BodyProxy.new(body) { log(env, status, header, began_at) }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
[status, header, body]
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
data/puma.gemspec
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
|
2
|
-
|
|
3
|
-
Gem::Specification.new do |s|
|
|
4
|
-
s.name = "puma"
|
|
5
|
-
s.version = "2.1.1"
|
|
6
|
-
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
|
-
s.authors = ["Evan Phoenix"]
|
|
9
|
-
s.date = "2013-06-20"
|
|
10
|
-
s.description = "Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications. Puma is intended for use in both development and production environments. In order to get the best throughput, it is highly recommended that you use a Ruby implementation with real threads like Rubinius or JRuby."
|
|
11
|
-
s.email = ["evan@phx.io"]
|
|
12
|
-
s.executables = ["puma", "pumactl"]
|
|
13
|
-
s.extensions = ["ext/puma_http11/extconf.rb"]
|
|
14
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.md", "docs/config.md", "docs/nginx.md", "tools/jungle/init.d/README.md", "tools/jungle/upstart/README.md"]
|
|
15
|
-
s.files = ["COPYING", "Gemfile", "History.txt", "LICENSE", "Manifest.txt", "README.md", "Rakefile", "TODO", "bin/puma", "bin/pumactl", "docs/config.md", "docs/nginx.md", "ext/puma_http11/PumaHttp11Service.java", "ext/puma_http11/ext_help.h", "ext/puma_http11/extconf.rb", "ext/puma_http11/http11_parser.c", "ext/puma_http11/http11_parser.h", "ext/puma_http11/http11_parser.java.rl", "ext/puma_http11/http11_parser.rl", "ext/puma_http11/http11_parser_common.rl", "ext/puma_http11/io_buffer.c", "ext/puma_http11/mini_ssl.c", "ext/puma_http11/org/jruby/puma/Http11.java", "ext/puma_http11/org/jruby/puma/Http11Parser.java", "ext/puma_http11/org/jruby/puma/MiniSSL.java", "ext/puma_http11/puma_http11.c", "lib/puma.rb", "lib/puma/accept_nonblock.rb", "lib/puma/app/status.rb", "lib/puma/binder.rb", "lib/puma/capistrano.rb", "lib/puma/cli.rb", "lib/puma/client.rb", "lib/puma/compat.rb", "lib/puma/configuration.rb", "lib/puma/const.rb", "lib/puma/control_cli.rb", "lib/puma/daemon_ext.rb", "lib/puma/delegation.rb", "lib/puma/detect.rb", "lib/puma/events.rb", "lib/puma/io_buffer.rb", "lib/puma/java_io_buffer.rb", "lib/puma/jruby_restart.rb", "lib/puma/minissl.rb", "lib/puma/null_io.rb", "lib/puma/rack_default.rb", "lib/puma/rack_patch.rb", "lib/puma/reactor.rb", "lib/puma/server.rb", "lib/puma/thread_pool.rb", "lib/puma/util.rb", "lib/rack/handler/puma.rb", "puma.gemspec", "tools/jungle/init.d/README.md", "tools/jungle/init.d/puma", "tools/jungle/init.d/run-puma", "tools/jungle/upstart/README.md", "tools/jungle/upstart/puma-manager.conf", "tools/jungle/upstart/puma.conf", "test/test_app_status.rb", "test/test_cli.rb", "test/test_config.rb", "test/test_http10.rb", "test/test_http11.rb", "test/test_integration.rb", "test/test_iobuffer.rb", "test/test_minissl.rb", "test/test_null_io.rb", "test/test_persistent.rb", "test/test_puma_server.rb", "test/test_rack_handler.rb", "test/test_rack_server.rb", "test/test_thread_pool.rb", "test/test_unix_socket.rb", "test/test_ws.rb"]
|
|
16
|
-
s.homepage = "http://puma.io"
|
|
17
|
-
s.rdoc_options = ["--main", "README.md"]
|
|
18
|
-
s.require_paths = ["lib"]
|
|
19
|
-
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
|
20
|
-
s.rubyforge_project = "puma"
|
|
21
|
-
s.rubygems_version = "1.8.25"
|
|
22
|
-
s.summary = "Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications"
|
|
23
|
-
s.test_files = ["test/test_app_status.rb", "test/test_cli.rb", "test/test_config.rb", "test/test_http10.rb", "test/test_http11.rb", "test/test_integration.rb", "test/test_iobuffer.rb", "test/test_minissl.rb", "test/test_null_io.rb", "test/test_persistent.rb", "test/test_puma_server.rb", "test/test_rack_handler.rb", "test/test_rack_server.rb", "test/test_thread_pool.rb", "test/test_unix_socket.rb", "test/test_ws.rb"]
|
|
24
|
-
|
|
25
|
-
if s.respond_to? :specification_version then
|
|
26
|
-
s.specification_version = 3
|
|
27
|
-
|
|
28
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
29
|
-
s.add_runtime_dependency(%q<rack>, ["< 2.0", ">= 1.1"])
|
|
30
|
-
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
|
31
|
-
s.add_development_dependency(%q<rake-compiler>, ["~> 0.8.0"])
|
|
32
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.6"])
|
|
33
|
-
else
|
|
34
|
-
s.add_dependency(%q<rack>, ["< 2.0", ">= 1.1"])
|
|
35
|
-
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
|
36
|
-
s.add_dependency(%q<rake-compiler>, ["~> 0.8.0"])
|
|
37
|
-
s.add_dependency(%q<hoe>, ["~> 3.6"])
|
|
38
|
-
end
|
|
39
|
-
else
|
|
40
|
-
s.add_dependency(%q<rack>, ["< 2.0", ">= 1.1"])
|
|
41
|
-
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
|
42
|
-
s.add_dependency(%q<rake-compiler>, ["~> 0.8.0"])
|
|
43
|
-
s.add_dependency(%q<hoe>, ["~> 3.6"])
|
|
44
|
-
end
|
|
45
|
-
end
|
data/test/test_app_status.rb
DELETED
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
require 'test/unit'
|
|
2
|
-
require 'rack'
|
|
3
|
-
require 'puma/app/status'
|
|
4
|
-
|
|
5
|
-
class TestAppStatus < Test::Unit::TestCase
|
|
6
|
-
class FakeServer
|
|
7
|
-
def initialize
|
|
8
|
-
@status = :running
|
|
9
|
-
@backlog = 0
|
|
10
|
-
@running = 0
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
attr_reader :status
|
|
14
|
-
attr_accessor :backlog, :running
|
|
15
|
-
|
|
16
|
-
def stop
|
|
17
|
-
@status = :stop
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def halt
|
|
21
|
-
@status = :halt
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def setup
|
|
26
|
-
@server = FakeServer.new
|
|
27
|
-
@app = Puma::App::Status.new(@server, @server)
|
|
28
|
-
@app.auth_token = nil
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def lint(uri)
|
|
32
|
-
app = Rack::Lint.new @app
|
|
33
|
-
mock_env = Rack::MockRequest.env_for uri
|
|
34
|
-
app.call mock_env
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def test_bad_token
|
|
38
|
-
@app.auth_token = "abcdef"
|
|
39
|
-
|
|
40
|
-
status, _, _ = lint('/whatever')
|
|
41
|
-
|
|
42
|
-
assert_equal 403, status
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_good_token
|
|
46
|
-
@app.auth_token = "abcdef"
|
|
47
|
-
|
|
48
|
-
status, _, _ = lint('/whatever?token=abcdef')
|
|
49
|
-
|
|
50
|
-
assert_equal 404, status
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def test_unsupported
|
|
54
|
-
status, _, _ = lint('/not-real')
|
|
55
|
-
|
|
56
|
-
assert_equal 404, status
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def test_stop
|
|
60
|
-
status, _ , app = lint('/stop')
|
|
61
|
-
|
|
62
|
-
assert_equal :stop, @server.status
|
|
63
|
-
assert_equal 200, status
|
|
64
|
-
assert_equal ['{ "status": "ok" }'], app.enum_for.to_a
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def test_halt
|
|
68
|
-
status, _ , app = lint('/halt')
|
|
69
|
-
|
|
70
|
-
assert_equal :halt, @server.status
|
|
71
|
-
assert_equal 200, status
|
|
72
|
-
assert_equal ['{ "status": "ok" }'], app.enum_for.to_a
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def test_stats
|
|
76
|
-
@server.backlog = 1
|
|
77
|
-
@server.running = 9
|
|
78
|
-
status, _ , app = lint('/stats')
|
|
79
|
-
|
|
80
|
-
assert_equal 200, status
|
|
81
|
-
assert_equal ['{ "backlog": 1, "running": 9 }'], app.enum_for.to_a
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def test_alternate_location
|
|
85
|
-
status, _ , _ = lint('__alternatE_location_/stats')
|
|
86
|
-
assert_equal 200, status
|
|
87
|
-
end
|
|
88
|
-
end
|