puma 3.8.2 → 4.3.12
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 +5 -5
- data/History.md +305 -0
- data/LICENSE +0 -0
- data/README.md +162 -224
- data/bin/puma-wild +0 -0
- data/docs/architecture.md +37 -0
- data/{DEPLOYMENT.md → docs/deployment.md} +24 -4
- 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/nginx.md +0 -0
- data/docs/plugins.md +38 -0
- data/docs/restart.md +41 -0
- data/docs/signals.md +56 -3
- data/docs/systemd.md +130 -37
- data/docs/tcp_mode.md +96 -0
- data/ext/puma_http11/PumaHttp11Service.java +2 -0
- data/ext/puma_http11/ext_help.h +0 -0
- data/ext/puma_http11/extconf.rb +21 -0
- data/ext/puma_http11/http11_parser.c +134 -144
- data/ext/puma_http11/http11_parser.h +0 -0
- data/ext/puma_http11/http11_parser.java.rl +21 -37
- data/ext/puma_http11/http11_parser.rl +12 -10
- data/ext/puma_http11/http11_parser_common.rl +4 -4
- data/ext/puma_http11/io_buffer.c +0 -0
- data/ext/puma_http11/mini_ssl.c +165 -34
- data/ext/puma_http11/org/jruby/puma/Http11.java +106 -114
- data/ext/puma_http11/org/jruby/puma/Http11Parser.java +85 -101
- data/ext/puma_http11/org/jruby/puma/IOBuffer.java +72 -0
- data/ext/puma_http11/org/jruby/puma/MiniSSL.java +30 -6
- data/ext/puma_http11/puma_http11.c +3 -0
- data/lib/puma/accept_nonblock.rb +7 -1
- data/lib/puma/app/status.rb +42 -26
- data/lib/puma/binder.rb +57 -74
- data/lib/puma/cli.rb +26 -7
- data/lib/puma/client.rb +307 -191
- data/lib/puma/cluster.rb +78 -34
- data/lib/puma/commonlogger.rb +2 -0
- data/lib/puma/configuration.rb +24 -16
- data/lib/puma/const.rb +41 -20
- data/lib/puma/control_cli.rb +46 -19
- data/lib/puma/detect.rb +2 -0
- data/lib/puma/dsl.rb +329 -68
- data/lib/puma/events.rb +6 -2
- data/lib/puma/io_buffer.rb +3 -6
- data/lib/puma/jruby_restart.rb +2 -1
- data/lib/puma/launcher.rb +125 -61
- data/lib/puma/minissl/context_builder.rb +76 -0
- data/lib/puma/minissl.rb +85 -28
- data/lib/puma/null_io.rb +2 -0
- data/lib/puma/plugin/tmp_restart.rb +2 -1
- data/lib/puma/plugin.rb +7 -2
- data/lib/puma/rack/builder.rb +4 -1
- data/lib/puma/rack/urlmap.rb +2 -0
- data/lib/puma/rack_default.rb +2 -0
- data/lib/puma/reactor.rb +224 -34
- data/lib/puma/runner.rb +27 -6
- data/lib/puma/server.rb +212 -68
- data/lib/puma/single.rb +16 -5
- data/lib/puma/state_file.rb +2 -0
- data/lib/puma/tcp_logger.rb +2 -0
- data/lib/puma/thread_pool.rb +67 -36
- data/lib/puma/util.rb +2 -6
- data/lib/puma.rb +16 -0
- data/lib/rack/handler/puma.rb +16 -5
- data/tools/docker/Dockerfile +16 -0
- data/tools/jungle/README.md +12 -2
- data/tools/jungle/init.d/README.md +2 -0
- data/tools/jungle/init.d/puma +8 -8
- data/tools/jungle/init.d/run-puma +1 -1
- data/tools/jungle/rc.d/README.md +74 -0
- data/tools/jungle/rc.d/puma +61 -0
- data/tools/jungle/rc.d/puma.conf +10 -0
- data/tools/jungle/upstart/README.md +0 -0
- data/tools/jungle/upstart/puma-manager.conf +0 -0
- data/tools/jungle/upstart/puma.conf +0 -0
- data/tools/trickletest.rb +1 -2
- metadata +32 -93
- data/.github/issue_template.md +0 -20
- data/Gemfile +0 -12
- data/Manifest.txt +0 -78
- data/Rakefile +0 -158
- data/Release.md +0 -9
- data/gemfiles/2.1-Gemfile +0 -12
- data/lib/puma/compat.rb +0 -14
- data/lib/puma/convenient.rb +0 -23
- data/lib/puma/daemon_ext.rb +0 -31
- data/lib/puma/delegation.rb +0 -11
- data/lib/puma/java_io_buffer.rb +0 -45
- data/lib/puma/rack/backports/uri/common_193.rb +0 -33
- data/puma.gemspec +0 -52
data/lib/puma/thread_pool.rb
CHANGED
@@ -1,8 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'thread'
|
2
4
|
|
3
5
|
module Puma
|
4
|
-
# A simple thread pool management object.
|
6
|
+
# Internal Docs for A simple thread pool management object.
|
7
|
+
#
|
8
|
+
# Each Puma "worker" has a thread pool to process requests.
|
9
|
+
#
|
10
|
+
# First a connection to a client is made in `Puma::Server`. It is wrapped in a
|
11
|
+
# `Puma::Client` instance and then passed to the `Puma::Reactor` to ensure
|
12
|
+
# the whole request is buffered into memory. Once the request is ready, it is passed into
|
13
|
+
# a thread pool via the `Puma::ThreadPool#<<` operator where it is stored in a `@todo` array.
|
5
14
|
#
|
15
|
+
# Each thread in the pool has an internal loop where it pulls a request from the `@todo` array
|
16
|
+
# and proceses it.
|
6
17
|
class ThreadPool
|
7
18
|
class ForceShutdown < RuntimeError
|
8
19
|
end
|
@@ -49,11 +60,11 @@ module Puma
|
|
49
60
|
@clean_thread_locals = false
|
50
61
|
end
|
51
62
|
|
52
|
-
attr_reader :spawned, :trim_requested
|
63
|
+
attr_reader :spawned, :trim_requested, :waiting
|
53
64
|
attr_accessor :clean_thread_locals
|
54
65
|
|
55
66
|
def self.clean_thread_locals
|
56
|
-
Thread.current.keys.each do |key|
|
67
|
+
Thread.current.keys.each do |key| # rubocop: disable Performance/HashEachMethods
|
57
68
|
Thread.current[key] = nil unless key == :__recursive_key__
|
58
69
|
end
|
59
70
|
end
|
@@ -64,6 +75,10 @@ module Puma
|
|
64
75
|
@mutex.synchronize { @todo.size }
|
65
76
|
end
|
66
77
|
|
78
|
+
def pool_capacity
|
79
|
+
waiting + (@max - spawned)
|
80
|
+
end
|
81
|
+
|
67
82
|
# :nodoc:
|
68
83
|
#
|
69
84
|
# Must be called with @mutex held!
|
@@ -71,9 +86,8 @@ module Puma
|
|
71
86
|
def spawn_thread
|
72
87
|
@spawned += 1
|
73
88
|
|
74
|
-
th = Thread.new do
|
75
|
-
|
76
|
-
Thread.current.name = 'puma %03i' % @spawned if Thread.current.respond_to?(:name=)
|
89
|
+
th = Thread.new(@spawned) do |spawned|
|
90
|
+
Puma.set_thread_name 'threadpool %03i' % spawned
|
77
91
|
todo = @todo
|
78
92
|
block = @block
|
79
93
|
mutex = @mutex
|
@@ -153,9 +167,47 @@ module Puma
|
|
153
167
|
end
|
154
168
|
end
|
155
169
|
|
170
|
+
# This method is used by `Puma::Server` to let the server know when
|
171
|
+
# the thread pool can pull more requests from the socket and
|
172
|
+
# pass to the reactor.
|
173
|
+
#
|
174
|
+
# The general idea is that the thread pool can only work on a fixed
|
175
|
+
# number of requests at the same time. If it is already processing that
|
176
|
+
# number of requests then it is at capacity. If another Puma process has
|
177
|
+
# spare capacity, then the request can be left on the socket so the other
|
178
|
+
# worker can pick it up and process it.
|
179
|
+
#
|
180
|
+
# For example: if there are 5 threads, but only 4 working on
|
181
|
+
# requests, this method will not wait and the `Puma::Server`
|
182
|
+
# can pull a request right away.
|
183
|
+
#
|
184
|
+
# If there are 5 threads and all 5 of them are busy, then it will
|
185
|
+
# pause here, and wait until the `not_full` condition variable is
|
186
|
+
# signaled, usually this indicates that a request has been processed.
|
187
|
+
#
|
188
|
+
# It's important to note that even though the server might accept another
|
189
|
+
# request, it might not be added to the `@todo` array right away.
|
190
|
+
# For example if a slow client has only sent a header, but not a body
|
191
|
+
# then the `@todo` array would stay the same size as the reactor works
|
192
|
+
# to try to buffer the request. In that scenario the next call to this
|
193
|
+
# method would not block and another request would be added into the reactor
|
194
|
+
# by the server. This would continue until a fully bufferend request
|
195
|
+
# makes it through the reactor and can then be processed by the thread pool.
|
196
|
+
#
|
197
|
+
# Returns the current number of busy threads, or +nil+ if shutting down.
|
198
|
+
#
|
156
199
|
def wait_until_not_full
|
157
200
|
@mutex.synchronize do
|
158
|
-
|
201
|
+
while true
|
202
|
+
return if @shutdown
|
203
|
+
|
204
|
+
# If we can still spin up new threads and there
|
205
|
+
# is work queued that cannot be handled by waiting
|
206
|
+
# threads, then accept more work until we would
|
207
|
+
# spin up the max number of threads.
|
208
|
+
busy_threads = @spawned - @waiting + @todo.size
|
209
|
+
return busy_threads if @max > busy_threads
|
210
|
+
|
159
211
|
@not_full.wait @mutex
|
160
212
|
end
|
161
213
|
end
|
@@ -191,10 +243,12 @@ module Puma
|
|
191
243
|
end
|
192
244
|
end
|
193
245
|
|
194
|
-
class
|
195
|
-
def initialize(pool, timeout)
|
246
|
+
class Automaton
|
247
|
+
def initialize(pool, timeout, thread_name, message)
|
196
248
|
@pool = pool
|
197
249
|
@timeout = timeout
|
250
|
+
@thread_name = thread_name
|
251
|
+
@message = message
|
198
252
|
@running = false
|
199
253
|
end
|
200
254
|
|
@@ -202,8 +256,9 @@ module Puma
|
|
202
256
|
@running = true
|
203
257
|
|
204
258
|
@thread = Thread.new do
|
259
|
+
Puma.set_thread_name @thread_name
|
205
260
|
while @running
|
206
|
-
@pool.
|
261
|
+
@pool.public_send(@message)
|
207
262
|
sleep @timeout
|
208
263
|
end
|
209
264
|
end
|
@@ -216,36 +271,12 @@ module Puma
|
|
216
271
|
end
|
217
272
|
|
218
273
|
def auto_trim!(timeout=30)
|
219
|
-
@auto_trim =
|
274
|
+
@auto_trim = Automaton.new(self, timeout, "threadpool trimmer", :trim)
|
220
275
|
@auto_trim.start!
|
221
276
|
end
|
222
277
|
|
223
|
-
class Reaper
|
224
|
-
def initialize(pool, timeout)
|
225
|
-
@pool = pool
|
226
|
-
@timeout = timeout
|
227
|
-
@running = false
|
228
|
-
end
|
229
|
-
|
230
|
-
def start!
|
231
|
-
@running = true
|
232
|
-
|
233
|
-
@thread = Thread.new do
|
234
|
-
while @running
|
235
|
-
@pool.reap
|
236
|
-
sleep @timeout
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
def stop
|
242
|
-
@running = false
|
243
|
-
@thread.wakeup
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
278
|
def auto_reap!(timeout=5)
|
248
|
-
@reaper =
|
279
|
+
@reaper = Automaton.new(self, timeout, "threadpool reaper", :reap)
|
249
280
|
@reaper.start!
|
250
281
|
end
|
251
282
|
|
data/lib/puma/util.rb
CHANGED
@@ -1,10 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require 'puma/rack/backports/uri/common_193'
|
5
|
-
else
|
6
|
-
require 'uri/common'
|
7
|
-
end
|
3
|
+
require 'uri/common'
|
8
4
|
|
9
5
|
module Puma
|
10
6
|
module Util
|
data/lib/puma.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# Standard libraries
|
2
4
|
require 'socket'
|
3
5
|
require 'tempfile'
|
@@ -12,4 +14,18 @@ module Puma
|
|
12
14
|
autoload :Const, 'puma/const'
|
13
15
|
autoload :Server, 'puma/server'
|
14
16
|
autoload :Launcher, 'puma/launcher'
|
17
|
+
|
18
|
+
def self.stats_object=(val)
|
19
|
+
@get_stats = val
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.stats
|
23
|
+
@get_stats.stats
|
24
|
+
end
|
25
|
+
|
26
|
+
# Thread name is new in Ruby 2.3
|
27
|
+
def self.set_thread_name(name)
|
28
|
+
return unless Thread.current.respond_to?(:name=)
|
29
|
+
Thread.current.name = "puma #{name}"
|
30
|
+
end
|
15
31
|
end
|
data/lib/rack/handler/puma.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rack/handler'
|
2
4
|
|
3
5
|
module Rack
|
@@ -9,6 +11,7 @@ module Rack
|
|
9
11
|
}
|
10
12
|
|
11
13
|
def self.config(app, options = {})
|
14
|
+
require 'puma'
|
12
15
|
require 'puma/configuration'
|
13
16
|
require 'puma/events'
|
14
17
|
require 'puma/launcher'
|
@@ -21,7 +24,7 @@ module Rack
|
|
21
24
|
# contains an array of all explicitly defined user options. We then
|
22
25
|
# know that all other values are defaults
|
23
26
|
if user_supplied_options = options.delete(:user_supplied_options)
|
24
|
-
(options.keys - user_supplied_options).each do |k
|
27
|
+
(options.keys - user_supplied_options).each do |k|
|
25
28
|
default_options[k] = options.delete(k)
|
26
29
|
end
|
27
30
|
end
|
@@ -42,7 +45,15 @@ module Rack
|
|
42
45
|
user_config.threads min, max
|
43
46
|
end
|
44
47
|
|
45
|
-
|
48
|
+
if options[:Host] || options[:Port]
|
49
|
+
host = options[:Host] || default_options[:Host]
|
50
|
+
port = options[:Port] || default_options[:Port]
|
51
|
+
self.set_host_port_to_config(host, port, user_config)
|
52
|
+
end
|
53
|
+
|
54
|
+
if default_options[:Host]
|
55
|
+
file_config.set_default_host(default_options[:Host])
|
56
|
+
end
|
46
57
|
self.set_host_port_to_config(default_options[:Host], default_options[:Port], default_config)
|
47
58
|
|
48
59
|
user_config.app app
|
@@ -50,8 +61,6 @@ module Rack
|
|
50
61
|
conf
|
51
62
|
end
|
52
63
|
|
53
|
-
|
54
|
-
|
55
64
|
def self.run(app, options = {})
|
56
65
|
conf = self.config(app, options)
|
57
66
|
|
@@ -77,8 +86,10 @@ module Rack
|
|
77
86
|
"Verbose" => "Don't report each request (default: false)"
|
78
87
|
}
|
79
88
|
end
|
80
|
-
|
89
|
+
|
81
90
|
def self.set_host_port_to_config(host, port, config)
|
91
|
+
config.clear_binds! if host || port
|
92
|
+
|
82
93
|
if host && (host[0,1] == '.' || host[0,1] == '/')
|
83
94
|
config.bind "unix://#{host}"
|
84
95
|
elsif host && host =~ /^ssl:\/\//
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Use this Dockerfile to create minimal reproductions of issues
|
2
|
+
|
3
|
+
FROM ruby:2.6
|
4
|
+
|
5
|
+
# throw errors if Gemfile has been modified since Gemfile.lock
|
6
|
+
RUN bundle config --global frozen 1
|
7
|
+
|
8
|
+
WORKDIR /usr/src/app
|
9
|
+
|
10
|
+
COPY . .
|
11
|
+
RUN gem install bundler
|
12
|
+
RUN bundle install
|
13
|
+
RUN bundle exec rake compile
|
14
|
+
|
15
|
+
EXPOSE 9292
|
16
|
+
CMD bundle exec bin/puma test/rackup/hello.ru
|
data/tools/jungle/README.md
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
# Puma as a service
|
2
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
|
+
|
3
11
|
## Init.d
|
4
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
|
+
|
5
15
|
See `/tools/jungle/init.d` for tools to use with init.d and start-stop-daemon.
|
6
16
|
|
7
|
-
##
|
17
|
+
## rc.d
|
8
18
|
|
9
|
-
See `/tools/jungle/
|
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
|
data/tools/jungle/init.d/puma
CHANGED
@@ -47,11 +47,11 @@ do_start_one() {
|
|
47
47
|
PIDFILE=$1/tmp/puma/pid
|
48
48
|
if [ -e $PIDFILE ]; then
|
49
49
|
PID=`cat $PIDFILE`
|
50
|
-
# If the puma
|
51
|
-
if
|
52
|
-
do_start_one_do $1
|
53
|
-
else
|
50
|
+
# If the puma is running, restart it, otherwise run it.
|
51
|
+
if ps -p $PID > /dev/null; then
|
54
52
|
do_restart_one $1
|
53
|
+
else
|
54
|
+
do_start_one_do $1
|
55
55
|
fi
|
56
56
|
else
|
57
57
|
do_start_one_do $1
|
@@ -105,9 +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
|
109
|
-
log_daemon_msg "---> Puma $1 isn't running."
|
110
|
-
else
|
108
|
+
if ps -p $PID > /dev/null; then
|
111
109
|
log_daemon_msg "---> About to kill PID `cat $PIDFILE`"
|
112
110
|
if [ "$USE_LOCAL_BUNDLE" -eq 1 ]; then
|
113
111
|
cd $1 && bundle exec pumactl --state $STATEFILE stop
|
@@ -116,6 +114,8 @@ do_stop_one() {
|
|
116
114
|
fi
|
117
115
|
# Many daemons don't delete their pidfiles when they exit.
|
118
116
|
rm -f $PIDFILE $STATEFILE
|
117
|
+
else
|
118
|
+
log_daemon_msg "---> Puma $1 isn't running."
|
119
119
|
fi
|
120
120
|
else
|
121
121
|
log_daemon_msg "---> No puma here..."
|
@@ -398,7 +398,7 @@ case "$1" in
|
|
398
398
|
;;
|
399
399
|
remove)
|
400
400
|
if [ "$#" -lt 2 ]; then
|
401
|
-
echo "Please,
|
401
|
+
echo "Please, specify the app's directory to remove."
|
402
402
|
exit 1
|
403
403
|
else
|
404
404
|
do_remove $2
|
@@ -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"
|
File without changes
|
File without changes
|
File without changes
|
data/tools/trickletest.rb
CHANGED
@@ -31,14 +31,13 @@ st = "GET / HTTP/1.1\r\nHost: www.zedshaw.com\r\nContent-Type: text/plain\r\nCon
|
|
31
31
|
puts "length: #{content.length}"
|
32
32
|
|
33
33
|
threads = []
|
34
|
-
ARGV[1].to_i.times do
|
34
|
+
ARGV[1].to_i.times do
|
35
35
|
t = Thread.new do
|
36
36
|
size = 100
|
37
37
|
puts ">>>> #{size} sized chunks"
|
38
38
|
do_test(st, size)
|
39
39
|
end
|
40
40
|
|
41
|
-
t.abort_on_exception = true
|
42
41
|
threads << t
|
43
42
|
end
|
44
43
|
|