unicorn 5.0.1 → 5.1.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.olddoc.yml +3 -0
- data/Documentation/unicorn.1.txt +0 -1
- data/Documentation/unicorn_rails.1.txt +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/HACKING +1 -1
- data/README +5 -12
- data/ext/unicorn_http/unicorn_http.rl +23 -12
- data/lib/unicorn.rb +30 -19
- data/lib/unicorn/configurator.rb +3 -2
- data/lib/unicorn/http_response.rb +5 -2
- data/lib/unicorn/http_server.rb +2 -2
- data/test/unit/test_http_parser.rb +14 -0
- data/unicorn.gemspec +6 -6
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9df0daaf5a74d108be366eda7182bae25ecb7b80
|
4
|
+
data.tar.gz: 87025c9cc3947d5e98048dc91d5d23326be35943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e63553c9e2cc2716183087db8c23e74e1c99a731781665519ab31d897f675dcedcf38b8bd830f3bb8dc4f87acefdb63f5792da7145bf957cfda924929bfce88e
|
7
|
+
data.tar.gz: 1c9a4e70ea6e7f67633c164273bb46dda949858050f902eb3c58ca78f7bb81f1286bc5665fe14d0732167e547d2328a272027efb82417105a855e61fd7985cd2
|
data/.olddoc.yml
CHANGED
data/Documentation/unicorn.1.txt
CHANGED
data/GIT-VERSION-GEN
CHANGED
data/HACKING
CHANGED
@@ -57,7 +57,7 @@ Please wrap documentation at 72 characters-per-line or less (long URLs
|
|
57
57
|
are exempt) so it is comfortably readable from terminals.
|
58
58
|
|
59
59
|
When referencing mailing list posts, use
|
60
|
-
|
60
|
+
<tt>http://bogomips.org/unicorn-public/$MESSAGE_ID/</tt> if possible
|
61
61
|
since the Message-ID remains searchable even if a particular site
|
62
62
|
becomes unavailable.
|
63
63
|
|
data/README
CHANGED
@@ -13,7 +13,7 @@ both the the request and response in between unicorn and slow clients.
|
|
13
13
|
{nginx}[http://nginx.org/] or {Rack}[http://rack.github.io/].
|
14
14
|
|
15
15
|
* Compatible with Ruby 1.9.3 and later.
|
16
|
-
unicorn 4.
|
16
|
+
unicorn 4.x remains supported for Ruby 1.8 users.
|
17
17
|
|
18
18
|
* Process management: unicorn will reap and restart workers that
|
19
19
|
die from broken apps. There is no need to manage multiple processes
|
@@ -60,7 +60,7 @@ both the the request and response in between unicorn and slow clients.
|
|
60
60
|
|
61
61
|
== License
|
62
62
|
|
63
|
-
unicorn is copyright 2009 by all contributors (see logs in git).
|
63
|
+
unicorn is copyright 2009-2016 by all contributors (see logs in git).
|
64
64
|
It is based on Mongrel 1.1.5.
|
65
65
|
Mongrel is copyright 2007 Zed A. Shaw and contributors.
|
66
66
|
|
@@ -68,7 +68,7 @@ unicorn is licensed under (your choice) of the GPLv2 or later
|
|
68
68
|
(GPLv3+ preferred), or Ruby (1.8)-specific terms.
|
69
69
|
See the included LICENSE file for details.
|
70
70
|
|
71
|
-
unicorn is 100% Free Software.
|
71
|
+
unicorn is 100% Free Software (including all development tools used).
|
72
72
|
|
73
73
|
== Install
|
74
74
|
|
@@ -85,10 +85,9 @@ You can get the latest source via git from the following locations
|
|
85
85
|
git://bogomips.org/unicorn.git
|
86
86
|
git://repo.or.cz/unicorn.git (mirror)
|
87
87
|
|
88
|
-
You may browse the code from the web
|
89
|
-
tarballs here:
|
88
|
+
You may browse the code from the web:
|
90
89
|
|
91
|
-
* http://bogomips.org/unicorn.git
|
90
|
+
* http://bogomips.org/unicorn.git
|
92
91
|
* http://repo.or.cz/w/unicorn.git (gitweb)
|
93
92
|
|
94
93
|
See the HACKING guide on how to contribute and build prerelease gems
|
@@ -102,12 +101,6 @@ In APP_ROOT, run:
|
|
102
101
|
|
103
102
|
unicorn
|
104
103
|
|
105
|
-
=== Ancient Rails 1.2 - 2.x versions
|
106
|
-
|
107
|
-
In RAILS_ROOT, run:
|
108
|
-
|
109
|
-
unicorn_rails
|
110
|
-
|
111
104
|
unicorn will bind to all interfaces on TCP port 8080 by default.
|
112
105
|
You may use the +--listen/-l+ switch to bind to a different
|
113
106
|
address:port or a UNIX socket.
|
@@ -442,11 +442,31 @@ post_exec: /* "_out:" also goes here */
|
|
442
442
|
assert(hp->offset <= len && "offset longer than length");
|
443
443
|
}
|
444
444
|
|
445
|
+
static void hp_mark(void *ptr)
|
446
|
+
{
|
447
|
+
struct http_parser *hp = ptr;
|
448
|
+
|
449
|
+
rb_gc_mark(hp->buf);
|
450
|
+
rb_gc_mark(hp->env);
|
451
|
+
rb_gc_mark(hp->cont);
|
452
|
+
}
|
453
|
+
|
454
|
+
static size_t hp_memsize(const void *ptr)
|
455
|
+
{
|
456
|
+
return sizeof(struct http_parser);
|
457
|
+
}
|
458
|
+
|
459
|
+
static const rb_data_type_t hp_type = {
|
460
|
+
"unicorn_http",
|
461
|
+
{ hp_mark, RUBY_TYPED_DEFAULT_FREE, hp_memsize, /* reserved */ },
|
462
|
+
/* parent, data, [ flags ] */
|
463
|
+
};
|
464
|
+
|
445
465
|
static struct http_parser *data_get(VALUE self)
|
446
466
|
{
|
447
467
|
struct http_parser *hp;
|
448
468
|
|
449
|
-
|
469
|
+
TypedData_Get_Struct(self, struct http_parser, &hp_type, hp);
|
450
470
|
assert(hp && "failed to extract http_parser struct");
|
451
471
|
return hp;
|
452
472
|
}
|
@@ -552,21 +572,12 @@ static void finalize_header(struct http_parser *hp)
|
|
552
572
|
rb_hash_aset(hp->env, g_query_string, rb_str_new(NULL, 0));
|
553
573
|
}
|
554
574
|
|
555
|
-
static void hp_mark(void *ptr)
|
556
|
-
{
|
557
|
-
struct http_parser *hp = ptr;
|
558
|
-
|
559
|
-
rb_gc_mark(hp->buf);
|
560
|
-
rb_gc_mark(hp->env);
|
561
|
-
rb_gc_mark(hp->cont);
|
562
|
-
}
|
563
|
-
|
564
575
|
static VALUE HttpParser_alloc(VALUE klass)
|
565
576
|
{
|
566
577
|
struct http_parser *hp;
|
567
|
-
return Data_Make_Struct(klass, struct http_parser, hp_mark, -1, hp);
|
568
|
-
}
|
569
578
|
|
579
|
+
return TypedData_Make_Struct(klass, struct http_parser, &hp_type, hp);
|
580
|
+
}
|
570
581
|
|
571
582
|
/**
|
572
583
|
* call-seq:
|
data/lib/unicorn.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
# -*- encoding: binary -*-
|
2
2
|
require 'etc'
|
3
3
|
require 'stringio'
|
4
|
-
require 'rack'
|
5
4
|
require 'kgio'
|
6
5
|
|
6
|
+
begin
|
7
|
+
require 'rack'
|
8
|
+
rescue LoadError
|
9
|
+
warn 'rack not available, functionality reduced'
|
10
|
+
end
|
11
|
+
|
7
12
|
# :stopdoc:
|
8
13
|
# Unicorn module containing all of the classes (include C extensions) for
|
9
14
|
# running a Unicorn web server. It contains a minimalist HTTP server with just
|
@@ -20,7 +25,9 @@ module Unicorn
|
|
20
25
|
# application dispatch. This is always raised with an empty backtrace
|
21
26
|
# since there is nothing in the application stack that is responsible
|
22
27
|
# for client shutdowns/disconnects. This exception is visible to Rack
|
23
|
-
# applications unless PrereadInput middleware is loaded.
|
28
|
+
# applications unless PrereadInput middleware is loaded. This
|
29
|
+
# is a subclass of the standard EOFError class and applications should
|
30
|
+
# not rescue it explicitly, but rescue EOFError instead.
|
24
31
|
ClientShutdown = Class.new(EOFError)
|
25
32
|
|
26
33
|
# :stopdoc:
|
@@ -32,6 +39,9 @@ module Unicorn
|
|
32
39
|
def self.builder(ru, op)
|
33
40
|
# allow Configurator to parse cli switches embedded in the ru file
|
34
41
|
op = Unicorn::Configurator::RACKUP.merge!(:file => ru, :optparse => op)
|
42
|
+
if ru =~ /\.ru$/ && !defined?(Rack::Builder)
|
43
|
+
abort "rack and Rack::Builder must be available for processing #{ru}"
|
44
|
+
end
|
35
45
|
|
36
46
|
# Op is going to get cleared before the returned lambda is called, so
|
37
47
|
# save this value so that it's still there when we need it:
|
@@ -53,32 +63,33 @@ def self.builder(ru, op)
|
|
53
63
|
|
54
64
|
return inner_app if no_default_middleware
|
55
65
|
|
66
|
+
middleware = { # order matters
|
67
|
+
ContentLength: nil,
|
68
|
+
Chunked: nil,
|
69
|
+
CommonLogger: [ $stderr ],
|
70
|
+
ShowExceptions: nil,
|
71
|
+
Lint: nil,
|
72
|
+
TempfileReaper: nil,
|
73
|
+
}
|
74
|
+
|
56
75
|
# return value, matches rackup defaults based on env
|
57
76
|
# Unicorn does not support persistent connections, but Rainbows!
|
58
77
|
# and Zbatery both do. Users accustomed to the Rack::Server default
|
59
78
|
# middlewares will need ContentLength/Chunked middlewares.
|
60
79
|
case ENV["RACK_ENV"]
|
61
80
|
when "development"
|
62
|
-
Rack::Builder.new do
|
63
|
-
use Rack::ContentLength
|
64
|
-
use Rack::Chunked
|
65
|
-
use Rack::CommonLogger, $stderr
|
66
|
-
use Rack::ShowExceptions
|
67
|
-
use Rack::Lint
|
68
|
-
use Rack::TempfileReaper if Rack.const_defined?(:TempfileReaper)
|
69
|
-
run inner_app
|
70
|
-
end.to_app
|
71
81
|
when "deployment"
|
72
|
-
|
73
|
-
|
74
|
-
use Rack::Chunked
|
75
|
-
use Rack::CommonLogger, $stderr
|
76
|
-
use Rack::TempfileReaper if Rack.const_defined?(:TempfileReaper)
|
77
|
-
run inner_app
|
78
|
-
end.to_app
|
82
|
+
middleware.delete(:ShowExceptions)
|
83
|
+
middleware.delete(:Lint)
|
79
84
|
else
|
80
|
-
inner_app
|
85
|
+
return inner_app
|
81
86
|
end
|
87
|
+
Rack::Builder.new do
|
88
|
+
middleware.each do |m, args|
|
89
|
+
use(Rack.const_get(m), *args) if Rack.const_defined?(m)
|
90
|
+
end
|
91
|
+
run inner_app
|
92
|
+
end.to_app
|
82
93
|
end
|
83
94
|
end
|
84
95
|
|
data/lib/unicorn/configurator.rb
CHANGED
@@ -181,8 +181,6 @@ def before_exec(*args, &block)
|
|
181
181
|
# to have nginx always retry backends that may have had workers
|
182
182
|
# SIGKILL-ed due to timeouts.
|
183
183
|
#
|
184
|
-
# # See http://wiki.nginx.org/NginxHttpUpstreamModule for more details
|
185
|
-
# # on nginx upstream configuration:
|
186
184
|
# upstream unicorn_backend {
|
187
185
|
# # for UNIX domain socket setups:
|
188
186
|
# server unix:/path/to/.unicorn.sock fail_timeout=0;
|
@@ -192,6 +190,9 @@ def before_exec(*args, &block)
|
|
192
190
|
# server 192.168.0.8:8080 fail_timeout=0;
|
193
191
|
# server 192.168.0.9:8080 fail_timeout=0;
|
194
192
|
# }
|
193
|
+
#
|
194
|
+
# See http://nginx.org/en/docs/http/ngx_http_upstream_module.html
|
195
|
+
# for more details on nginx upstream configuration.
|
195
196
|
def timeout(seconds)
|
196
197
|
set_int(:timeout, seconds, 3)
|
197
198
|
# POSIX says 31 days is the smallest allowed maximum timeout for select()
|
@@ -10,10 +10,13 @@
|
|
10
10
|
# is the job of Rack, with the exception of the "Date" and "Status" header.
|
11
11
|
module Unicorn::HttpResponse
|
12
12
|
|
13
|
+
STATUS_CODES = defined?(Rack::Utils::HTTP_STATUS_CODES) ?
|
14
|
+
Rack::Utils::HTTP_STATUS_CODES : {}
|
15
|
+
|
13
16
|
# internal API, code will always be common-enough-for-even-old-Rack
|
14
17
|
def err_response(code, response_start_sent)
|
15
18
|
"#{response_start_sent ? '' : 'HTTP/1.1 '}" \
|
16
|
-
"#{code} #{
|
19
|
+
"#{code} #{STATUS_CODES[code]}\r\n\r\n"
|
17
20
|
end
|
18
21
|
|
19
22
|
# writes the rack_response to socket as an HTTP response
|
@@ -23,7 +26,7 @@ def http_response_write(socket, status, headers, body,
|
|
23
26
|
|
24
27
|
if headers
|
25
28
|
code = status.to_i
|
26
|
-
msg =
|
29
|
+
msg = STATUS_CODES[code]
|
27
30
|
start = response_start_sent ? ''.freeze : 'HTTP/1.1 '.freeze
|
28
31
|
buf = "#{start}#{msg ? %Q(#{code} #{msg}) : status}\r\n" \
|
29
32
|
"Date: #{httpdate}\r\n" \
|
data/lib/unicorn/http_server.rb
CHANGED
@@ -36,7 +36,7 @@ class Unicorn::HttpServer
|
|
36
36
|
# or even different installations of the same applications without
|
37
37
|
# downtime. Keys of this constant Hash are described as follows:
|
38
38
|
#
|
39
|
-
# * 0 - the path to the unicorn
|
39
|
+
# * 0 - the path to the unicorn executable
|
40
40
|
# * :argv - a deep copy of the ARGV array the executable originally saw
|
41
41
|
# * :cwd - the working directory of the application, this is where
|
42
42
|
# you originally started Unicorn.
|
@@ -45,7 +45,7 @@ class Unicorn::HttpServer
|
|
45
45
|
# you can set the following in your Unicorn config file, HUP and then
|
46
46
|
# continue with the traditional USR2 + QUIT upgrade steps:
|
47
47
|
#
|
48
|
-
# Unicorn::HttpServer::START_CTX[0] = "/home/bofh/2.
|
48
|
+
# Unicorn::HttpServer::START_CTX[0] = "/home/bofh/2.3.0/bin/unicorn"
|
49
49
|
START_CTX = {
|
50
50
|
:argv => ARGV.map(&:dup),
|
51
51
|
0 => $0.dup,
|
@@ -851,4 +851,18 @@ def test_memory_leak
|
|
851
851
|
File.readable?(LINUX_PROC_PID_STATUS) &&
|
852
852
|
!defined?(RUBY_ENGINE)
|
853
853
|
|
854
|
+
def test_memsize
|
855
|
+
require 'objspace'
|
856
|
+
if ObjectSpace.respond_to?(:memsize_of)
|
857
|
+
n = ObjectSpace.memsize_of(Unicorn::HttpParser.new)
|
858
|
+
assert_kind_of Integer, n
|
859
|
+
# need to update this when 128-bit machines come out
|
860
|
+
# n.b. actual struct size on 64-bit is 56 bytes + 40 bytes for RVALUE
|
861
|
+
# Ruby <= 2.2 objspace did not count the 40-byte RVALUE, 2.3 does.
|
862
|
+
assert_operator n, :<=, 96
|
863
|
+
assert_operator n, :>, 0
|
864
|
+
end
|
865
|
+
rescue LoadError
|
866
|
+
# not all Ruby implementations have objspace
|
867
|
+
end
|
854
868
|
end
|
data/unicorn.gemspec
CHANGED
@@ -31,16 +31,16 @@
|
|
31
31
|
# version requirements here.
|
32
32
|
s.required_ruby_version = '< 3.0'
|
33
33
|
|
34
|
-
#
|
35
|
-
#
|
36
|
-
#
|
37
|
-
|
38
|
-
|
34
|
+
# We do not have a hard dependency on rack, it's possible to load
|
35
|
+
# things which respond to #call. HTTP status lines in responses
|
36
|
+
# won't have descriptive text, only the numeric status.
|
37
|
+
s.add_development_dependency(%q<rack>)
|
38
|
+
|
39
39
|
s.add_dependency(%q<kgio>, '~> 2.6')
|
40
40
|
s.add_dependency(%q<raindrops>, '~> 0.7')
|
41
41
|
|
42
42
|
s.add_development_dependency('test-unit', '~> 3.0')
|
43
|
-
s.add_development_dependency('olddoc', '~> 1.
|
43
|
+
s.add_development_dependency('olddoc', '~> 1.2')
|
44
44
|
|
45
45
|
# Note: To avoid ambiguity, we intentionally avoid the SPDX-compatible
|
46
46
|
# 'Ruby' here since Ruby 1.9.3 switched to BSD-2-Clause, but we
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: unicorn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.1.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- unicorn hackers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -17,7 +17,7 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
type: :
|
20
|
+
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '1.
|
75
|
+
version: '1.2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '1.
|
82
|
+
version: '1.2'
|
83
83
|
description: |-
|
84
84
|
unicorn is an HTTP server for Rack applications designed to only serve
|
85
85
|
fast clients on low-latency, high-bandwidth connections and take
|
@@ -296,12 +296,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
296
296
|
version: '3.0'
|
297
297
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
298
298
|
requirements:
|
299
|
-
- - "
|
299
|
+
- - ">"
|
300
300
|
- !ruby/object:Gem::Version
|
301
|
-
version:
|
301
|
+
version: 1.3.1
|
302
302
|
requirements: []
|
303
303
|
rubyforge_project:
|
304
|
-
rubygems_version: 2.5.
|
304
|
+
rubygems_version: 2.5.1
|
305
305
|
signing_key:
|
306
306
|
specification_version: 4
|
307
307
|
summary: Rack HTTP server for fast clients and Unix
|