puma 2.16.0 → 3.0.0.rc1
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/Manifest.txt +5 -0
- data/README.md +4 -1
- data/ext/puma_http11/http11_parser.java.rl +5 -5
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +39 -39
- data/lib/puma.rb +1 -0
- data/lib/puma/app/status.rb +1 -1
- data/lib/puma/binder.rb +6 -1
- data/lib/puma/cli.rb +125 -494
- data/lib/puma/cluster.rb +21 -18
- data/lib/puma/configuration.rb +189 -58
- data/lib/puma/const.rb +2 -2
- data/lib/puma/control_cli.rb +57 -72
- data/lib/puma/convenient.rb +23 -0
- data/lib/puma/daemon_ext.rb +6 -0
- data/lib/puma/detect.rb +8 -1
- data/lib/puma/dsl.rb +105 -26
- data/lib/puma/events.rb +5 -0
- data/lib/puma/launcher.rb +397 -0
- data/lib/puma/null_io.rb +15 -0
- data/lib/puma/plugin.rb +91 -0
- data/lib/puma/plugin/tmp_restart.rb +23 -0
- data/lib/puma/runner.rb +19 -14
- data/lib/puma/server.rb +1 -0
- data/lib/puma/single.rb +9 -4
- data/lib/puma/state_file.rb +27 -0
- data/lib/rack/handler/puma.rb +26 -27
- metadata +9 -4
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'puma/plugin'
|
2
|
+
|
3
|
+
Puma::Plugin.create do
|
4
|
+
def start(launcher)
|
5
|
+
path = File.join("tmp", "restart.txt")
|
6
|
+
|
7
|
+
File.write path, ""
|
8
|
+
|
9
|
+
orig = File.stat(path).mtime
|
10
|
+
|
11
|
+
in_background do
|
12
|
+
while true
|
13
|
+
sleep 2
|
14
|
+
|
15
|
+
if File.stat(path).mtime > orig
|
16
|
+
launcher.restart
|
17
|
+
break
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
data/lib/puma/runner.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module Puma
|
2
2
|
class Runner
|
3
|
-
def initialize(cli)
|
4
|
-
@
|
3
|
+
def initialize(cli, events)
|
4
|
+
@launcher = cli
|
5
|
+
@events = events
|
5
6
|
@options = cli.options
|
6
7
|
@app = nil
|
7
8
|
@control = nil
|
@@ -16,15 +17,19 @@ module Puma
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def log(str)
|
19
|
-
@
|
20
|
+
@events.log str
|
21
|
+
end
|
22
|
+
|
23
|
+
def before_restart
|
24
|
+
@control.stop(true) if @control
|
20
25
|
end
|
21
26
|
|
22
27
|
def error(str)
|
23
|
-
@
|
28
|
+
@events.error str
|
24
29
|
end
|
25
30
|
|
26
|
-
def
|
27
|
-
@
|
31
|
+
def debug(str)
|
32
|
+
@events.log "- #{str}" if @options[:debug]
|
28
33
|
end
|
29
34
|
|
30
35
|
def start_control
|
@@ -35,13 +40,13 @@ module Puma
|
|
35
40
|
|
36
41
|
uri = URI.parse str
|
37
42
|
|
38
|
-
app = Puma::App::Status.new @
|
43
|
+
app = Puma::App::Status.new @launcher
|
39
44
|
|
40
45
|
if token = @options[:control_auth_token]
|
41
46
|
app.auth_token = token unless token.empty? or token == :none
|
42
47
|
end
|
43
48
|
|
44
|
-
control = Puma::Server.new app, @
|
49
|
+
control = Puma::Server.new app, @launcher.events
|
45
50
|
control.min_threads = 0
|
46
51
|
control.max_threads = 1
|
47
52
|
|
@@ -104,34 +109,34 @@ module Puma
|
|
104
109
|
end
|
105
110
|
|
106
111
|
def load_and_bind
|
107
|
-
unless @
|
112
|
+
unless @launcher.config.app_configured?
|
108
113
|
error "No application configured, nothing to run"
|
109
114
|
exit 1
|
110
115
|
end
|
111
116
|
|
112
117
|
# Load the app before we daemonize.
|
113
118
|
begin
|
114
|
-
@app = @
|
119
|
+
@app = @launcher.config.app
|
115
120
|
rescue Exception => e
|
116
121
|
log "! Unable to load application: #{e.class}: #{e.message}"
|
117
122
|
raise e
|
118
123
|
end
|
119
124
|
|
120
|
-
@
|
125
|
+
@launcher.binder.parse @options[:binds], self
|
121
126
|
end
|
122
127
|
|
123
128
|
def app
|
124
|
-
@app ||= @
|
129
|
+
@app ||= @launcher.config.app
|
125
130
|
end
|
126
131
|
|
127
132
|
def start_server
|
128
133
|
min_t = @options[:min_threads]
|
129
134
|
max_t = @options[:max_threads]
|
130
135
|
|
131
|
-
server = Puma::Server.new app, @
|
136
|
+
server = Puma::Server.new app, @launcher.events, @options
|
132
137
|
server.min_threads = min_t
|
133
138
|
server.max_threads = max_t
|
134
|
-
server.inherit_binder @
|
139
|
+
server.inherit_binder @launcher.binder
|
135
140
|
|
136
141
|
if @options[:mode] == :tcp
|
137
142
|
server.tcp_mode!
|
data/lib/puma/server.rb
CHANGED
data/lib/puma/single.rb
CHANGED
@@ -27,7 +27,12 @@ module Puma
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def jruby_daemon?
|
30
|
-
daemon? and
|
30
|
+
daemon? and Puma.jruby?
|
31
|
+
end
|
32
|
+
|
33
|
+
def jruby_daemon_start
|
34
|
+
require 'puma/jruby_restart'
|
35
|
+
JRubyRestart.daemon_start(@restart_dir, restart_args)
|
31
36
|
end
|
32
37
|
|
33
38
|
def run
|
@@ -66,7 +71,7 @@ module Puma
|
|
66
71
|
exit 1
|
67
72
|
end
|
68
73
|
|
69
|
-
pid =
|
74
|
+
pid = jruby_daemon_start
|
70
75
|
sleep
|
71
76
|
end
|
72
77
|
else
|
@@ -79,7 +84,7 @@ module Puma
|
|
79
84
|
load_and_bind
|
80
85
|
end
|
81
86
|
|
82
|
-
@
|
87
|
+
@launcher.write_state
|
83
88
|
|
84
89
|
start_control
|
85
90
|
|
@@ -90,7 +95,7 @@ module Puma
|
|
90
95
|
redirect_io
|
91
96
|
end
|
92
97
|
|
93
|
-
@
|
98
|
+
@launcher.events.fire_on_booted!
|
94
99
|
|
95
100
|
begin
|
96
101
|
server.run.join
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Puma
|
2
|
+
class StateFile
|
3
|
+
def initialize
|
4
|
+
@options = {}
|
5
|
+
end
|
6
|
+
|
7
|
+
def save(path)
|
8
|
+
File.write path, YAML.dump(@options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def load(path)
|
12
|
+
@options = YAML.load File.read(path)
|
13
|
+
end
|
14
|
+
|
15
|
+
FIELDS = %w!control_url control_auth_token pid!
|
16
|
+
|
17
|
+
FIELDS.each do |f|
|
18
|
+
define_method f do
|
19
|
+
@options[f]
|
20
|
+
end
|
21
|
+
|
22
|
+
define_method "#{f}=" do |v|
|
23
|
+
@options[f] = v
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/rack/handler/puma.rb
CHANGED
@@ -5,48 +5,47 @@ module Rack
|
|
5
5
|
module Handler
|
6
6
|
module Puma
|
7
7
|
DEFAULT_OPTIONS = {
|
8
|
-
:Host => '0.0.0.0',
|
9
|
-
:Port => 8080,
|
10
|
-
:Threads => '0:16',
|
11
8
|
:Verbose => false,
|
12
|
-
:Silent
|
9
|
+
:Silent => false
|
13
10
|
}
|
14
11
|
|
15
12
|
def self.run(app, options = {})
|
16
13
|
options = DEFAULT_OPTIONS.merge(options)
|
17
14
|
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
conf = ::Puma::Configuration.new do |c|
|
16
|
+
if options.delete(:Verbose)
|
17
|
+
app = Rack::CommonLogger.new(app, STDOUT)
|
18
|
+
end
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
if options[:environment]
|
21
|
+
c.environment options[:environment]
|
22
|
+
end
|
23
|
+
|
24
|
+
if options[:Threads]
|
25
|
+
min, max = options.delete(:Threads).split(':', 2)
|
26
|
+
c.threads min, max
|
27
|
+
end
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
min, max = options[:Threads].split(':', 2)
|
29
|
+
host = options[:Host] || ::Puma::Configuration::DefaultTCPHost
|
30
|
+
port = options[:Port] || ::Puma::Configuration::DefaultTCPPort
|
29
31
|
|
30
|
-
|
32
|
+
c.port port, host
|
31
33
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
c.app app
|
35
|
+
end
|
36
|
+
|
37
|
+
events = options.delete(:Silent) ? ::Puma::Events.strings : ::Puma::Events.stdio
|
36
38
|
|
37
|
-
|
38
|
-
server.min_threads = min
|
39
|
-
server.max_threads = max
|
40
|
-
yield server if block_given?
|
39
|
+
launcher = ::Puma::Launcher.new(conf, :events => events)
|
41
40
|
|
41
|
+
yield launcher if block_given?
|
42
42
|
begin
|
43
|
-
|
43
|
+
launcher.run
|
44
44
|
rescue Interrupt
|
45
|
-
|
46
|
-
|
47
|
-
|
45
|
+
puts "* Gracefully stopping, waiting for requests to finish"
|
46
|
+
launcher.stop
|
47
|
+
puts "* Goodbye!"
|
48
48
|
end
|
49
|
-
|
50
49
|
end
|
51
50
|
|
52
51
|
def self.valid_options
|
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:
|
4
|
+
version: 3.0.0.rc1
|
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-
|
11
|
+
date: 2016-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -136,6 +136,7 @@ files:
|
|
136
136
|
- lib/puma/configuration.rb
|
137
137
|
- lib/puma/const.rb
|
138
138
|
- lib/puma/control_cli.rb
|
139
|
+
- lib/puma/convenient.rb
|
139
140
|
- lib/puma/daemon_ext.rb
|
140
141
|
- lib/puma/delegation.rb
|
141
142
|
- lib/puma/detect.rb
|
@@ -144,8 +145,11 @@ files:
|
|
144
145
|
- lib/puma/io_buffer.rb
|
145
146
|
- lib/puma/java_io_buffer.rb
|
146
147
|
- lib/puma/jruby_restart.rb
|
148
|
+
- lib/puma/launcher.rb
|
147
149
|
- lib/puma/minissl.rb
|
148
150
|
- lib/puma/null_io.rb
|
151
|
+
- lib/puma/plugin.rb
|
152
|
+
- lib/puma/plugin/tmp_restart.rb
|
149
153
|
- lib/puma/rack/backports/uri/common_18.rb
|
150
154
|
- lib/puma/rack/backports/uri/common_192.rb
|
151
155
|
- lib/puma/rack/backports/uri/common_193.rb
|
@@ -156,6 +160,7 @@ files:
|
|
156
160
|
- lib/puma/runner.rb
|
157
161
|
- lib/puma/server.rb
|
158
162
|
- lib/puma/single.rb
|
163
|
+
- lib/puma/state_file.rb
|
159
164
|
- lib/puma/tcp_logger.rb
|
160
165
|
- lib/puma/thread_pool.rb
|
161
166
|
- lib/puma/util.rb
|
@@ -186,9 +191,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
186
191
|
version: 1.8.7
|
187
192
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
193
|
requirements:
|
189
|
-
- - "
|
194
|
+
- - ">"
|
190
195
|
- !ruby/object:Gem::Version
|
191
|
-
version:
|
196
|
+
version: 1.3.1
|
192
197
|
requirements: []
|
193
198
|
rubyforge_project:
|
194
199
|
rubygems_version: 2.5.1
|