unicorn 5.0.1 → 5.1.0
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-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/HACKING +1 -1
- data/ISSUES +3 -5
- data/LATEST +36 -28
- data/NEWS +157 -0
- data/README +6 -18
- data/Sandbox +3 -3
- data/examples/unicorn@.service +2 -0
- data/ext/unicorn_http/unicorn_http.c +23 -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/lib/unicorn/version.rb +1 -1
- data/man/man1/unicorn.1 +0 -2
- data/man/man1/unicorn_rails.1 +1 -2
- data/test/unit/test_http_parser.rb +14 -0
- data/unicorn.gemspec +6 -6
- metadata +6 -10
- data/unicorn_1 +0 -1
- data/unicorn_rails_1 +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad413ab1a47428cacfbcae82684d4cbe36e77d33
|
4
|
+
data.tar.gz: 752c0ca2043e8e5e05558a7eb515b53f5e3107d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ca49a70bdc5a632797db82b10f30af7b3b4db10f856ef81b275d4e5b939454191aaae1883d0bb83129c7a95d3a697faec6e51ae2438ba5588f70ee6d04b73e7
|
7
|
+
data.tar.gz: d28bc86a89d0ebb29ecaec72f363e6c0991ab71e22c4ed43d44b9e6b8cc8c8b03939de84c005a91b8473d833cf691f42cb2c3684f5ac1d1c91c4af87c7f78fad
|
data/.olddoc.yml
CHANGED
data/Documentation/unicorn.1.txt
CHANGED
data/GIT-VERSION-FILE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
GIT_VERSION = 5.0
|
1
|
+
GIT_VERSION = 5.1.0
|
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/ISSUES
CHANGED
@@ -5,7 +5,7 @@ submit patches and/or obtain support after you have searched the
|
|
5
5
|
{email archives}[http://bogomips.org/unicorn-public/] and
|
6
6
|
{documentation}[http://unicorn.bogomips.org/].
|
7
7
|
|
8
|
-
* No subscription will ever be required to email
|
8
|
+
* No subscription will ever be required to email us
|
9
9
|
* Cc: all participants in a thread or commit, as subscription is optional
|
10
10
|
* Do not {top post}[http://catb.org/jargon/html/T/top-post.html] in replies
|
11
11
|
* Quote as little as possible of the message you're replying to
|
@@ -69,9 +69,7 @@ document distributed with git) on guidelines for patch submission.
|
|
69
69
|
* nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
|
70
70
|
* http://bogomips.org/unicorn-public/
|
71
71
|
|
72
|
-
|
73
|
-
feeds the mailing list. Subscription is optional, so Cc:
|
74
|
-
all participants.
|
72
|
+
Mailing list subscription is optional, so Cc: all participants.
|
75
73
|
|
76
74
|
You can follow along via NNTP:
|
77
75
|
|
@@ -86,7 +84,7 @@ Or Atom feeds:
|
|
86
84
|
also has links to per-thread Atom feeds and downloadable
|
87
85
|
mboxes.
|
88
86
|
|
89
|
-
You may
|
87
|
+
You may optionally subscribe via plain-text email:
|
90
88
|
|
91
89
|
mailto:unicorn-public+subscribe@bogomips.org
|
92
90
|
(and confirming the auto-reply)
|
data/LATEST
CHANGED
@@ -1,29 +1,37 @@
|
|
1
|
-
=== unicorn 5.
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
1
|
+
=== unicorn 5.1.0 - rack is optional, again / 2016-04-01 00:35 UTC
|
2
|
+
|
3
|
+
Note: no code changes since 5.1.0.pre1 from January.^WNo, wait,
|
4
|
+
last minute performance improvement added today. See below.
|
5
|
+
|
6
|
+
The big change is rack is not required (but still recommended).
|
7
|
+
Applications are expected to depend on rack on their own so they can
|
8
|
+
specify the version of rack they prefer without unicorn pulling
|
9
|
+
in a newer, potentially incompatible version.
|
10
|
+
|
11
|
+
unicorn will always attempt to work with multiple versions of rack
|
12
|
+
as practical.
|
13
|
+
|
14
|
+
The HTTP parser also switched to using the TypedData C-API for
|
15
|
+
extra type safety and memory usage accounting support in the
|
16
|
+
'objspace' extension.
|
17
|
+
|
18
|
+
Thanks to Adam Duke to bringing the rack change to our attention
|
19
|
+
and Aaron Patterson for helping with the matter.
|
20
|
+
|
21
|
+
Last minute change: we now support the new leftpad() syscall under
|
22
|
+
Linux for major performance and security improvement:
|
23
|
+
|
24
|
+
http://mid.gmane.org/1459463613-32473-1-git-send-email-richard@nod.at
|
25
|
+
|
26
|
+
8^H9 changes since 5.0.1:
|
27
|
+
|
28
|
+
http: TypedData C-API conversion
|
29
|
+
various documentation updates
|
30
|
+
doc: bump olddoc to ~> 1.2 for extra NNTP URL
|
31
|
+
rack is optional at runtime, required for dev
|
32
|
+
doc update for ClientShutdown exceptions class
|
33
|
+
unicorn 5.1.0.pre1 - rack is optional, again
|
34
|
+
doc: reference --keep-file-descriptors for "bundle exec"
|
35
|
+
doc: further trimming to reduce noise
|
36
|
+
use leftpad Linux syscall for speed!
|
29
37
|
|
data/NEWS
CHANGED
@@ -1,3 +1,160 @@
|
|
1
|
+
=== unicorn 5.1.0 - rack is optional, again / 2016-04-01 00:35 UTC
|
2
|
+
|
3
|
+
Note: no code changes since 5.1.0.pre1 from January.^WNo, wait,
|
4
|
+
last minute performance improvement added today. See below.
|
5
|
+
|
6
|
+
The big change is rack is not required (but still recommended).
|
7
|
+
Applications are expected to depend on rack on their own so they can
|
8
|
+
specify the version of rack they prefer without unicorn pulling
|
9
|
+
in a newer, potentially incompatible version.
|
10
|
+
|
11
|
+
unicorn will always attempt to work with multiple versions of rack
|
12
|
+
as practical.
|
13
|
+
|
14
|
+
The HTTP parser also switched to using the TypedData C-API for
|
15
|
+
extra type safety and memory usage accounting support in the
|
16
|
+
'objspace' extension.
|
17
|
+
|
18
|
+
Thanks to Adam Duke to bringing the rack change to our attention
|
19
|
+
and Aaron Patterson for helping with the matter.
|
20
|
+
|
21
|
+
Last minute change: we now support the new leftpad() syscall under
|
22
|
+
Linux for major performance and security improvement:
|
23
|
+
|
24
|
+
http://mid.gmane.org/1459463613-32473-1-git-send-email-richard@nod.at
|
25
|
+
|
26
|
+
8^H9 changes since 5.0.1:
|
27
|
+
|
28
|
+
http: TypedData C-API conversion
|
29
|
+
various documentation updates
|
30
|
+
doc: bump olddoc to ~> 1.2 for extra NNTP URL
|
31
|
+
rack is optional at runtime, required for dev
|
32
|
+
doc update for ClientShutdown exceptions class
|
33
|
+
unicorn 5.1.0.pre1 - rack is optional, again
|
34
|
+
doc: reference --keep-file-descriptors for "bundle exec"
|
35
|
+
doc: further trimming to reduce noise
|
36
|
+
use leftpad Linux syscall for speed!
|
37
|
+
|
38
|
+
=== unicorn 5.1.0.pre1 - rack is optional, again / 2016-01-27 23:08 UTC
|
39
|
+
|
40
|
+
The big change is rack is not required (but still recommended).
|
41
|
+
Applications are expected to depend on rack on their own so they can
|
42
|
+
specify the version of rack they prefer without unicorn pulling
|
43
|
+
in a newer, potentially incompatible version.
|
44
|
+
|
45
|
+
unicorn will always attempt to work with multiple versions of rack
|
46
|
+
as practical.
|
47
|
+
|
48
|
+
The HTTP parser also switched to using the TypedData C-API for
|
49
|
+
extra type safety and memory usage accounting support in the
|
50
|
+
'objspace' extension.
|
51
|
+
|
52
|
+
Thanks to Adam Duke to bringing the rack change to our attention
|
53
|
+
and Aaron Patterson for helping with the matter.
|
54
|
+
|
55
|
+
There might be more documentation-related changes before 5.1.0
|
56
|
+
final. I am considering dropping pandoc from manpage generation
|
57
|
+
and relying on pod2man (from Perl) because it has a wider install
|
58
|
+
base.
|
59
|
+
|
60
|
+
5 changes since v5.0.1:
|
61
|
+
|
62
|
+
http: TypedData C-API conversion
|
63
|
+
various documentation updates
|
64
|
+
doc: bump olddoc to ~> 1.2 for extra NNTP URL
|
65
|
+
rack is optional at runtime, required for dev
|
66
|
+
doc update for ClientShutdown exceptions class
|
67
|
+
|
68
|
+
=== unicorn 5.0.1 - continuing to violate Rack SPEC / 2015-11-17 22:44 UTC
|
69
|
+
|
70
|
+
Once again, we allow nil values in response headers. We've had
|
71
|
+
this bug since March 2009, and thus cannot expect existing
|
72
|
+
applications and middlewares running unicorn to fix this.
|
73
|
+
|
74
|
+
Unfortunately, supporting this bug contributes to application
|
75
|
+
server lock-in, but at least we'll document it as such.
|
76
|
+
|
77
|
+
Thanks to Owen Ou <o@heroku.com> for reporting this regression:
|
78
|
+
|
79
|
+
http://bogomips.org/unicorn-public/CAO47=rJa=zRcLn_Xm4v2cHPr6c0UswaFC_omYFEH+baSxHOWKQ@mail.gmail.com/
|
80
|
+
|
81
|
+
Additionally, systemd examples are now in the examples/ directory
|
82
|
+
based on a post by Christos Trochalakis <yatiohi@ideopolis.gr>:
|
83
|
+
|
84
|
+
http://bogomips.org/unicorn-public/20150708130821.GA1361@luke.ws.skroutz.gr/
|
85
|
+
|
86
|
+
=== unicorn 5.0.0 - most boring major release. EVER. / 2015-11-01 08:48 UTC
|
87
|
+
|
88
|
+
An evolutionary dead-end since its announcement[1] nearly six years
|
89
|
+
ago, this old-fashioned preforker has had enough bugs and missteps
|
90
|
+
that it's managed to hit version 5!
|
91
|
+
|
92
|
+
I wish I could say unicorn 5 is leaps and bounds better than 4, but
|
93
|
+
it is not. This major version change allows us to drop some cruft
|
94
|
+
and unused features which accumulated over the years, resulting in
|
95
|
+
several kilobytes of memory saved[2]!
|
96
|
+
|
97
|
+
Compatibility:
|
98
|
+
|
99
|
+
* The horrible, proprietary (:P) "Status:" response header is
|
100
|
+
finally gone, saving at least 16 precious bytes in every HTTP
|
101
|
+
response. This should make it easier to write custom HTTP clients
|
102
|
+
which are compatible across all HTTP servers. It will hopefully
|
103
|
+
make migrating between different Rack servers easier for new
|
104
|
+
projects.
|
105
|
+
|
106
|
+
* Ruby 1.8 support removed. Ruby 1.9.3 is currently the earliest
|
107
|
+
supported version. However, expect minor, likely-unnoticeable
|
108
|
+
performance regressions if you use Ruby 2.1 or earlier. Going
|
109
|
+
forward, unicorn will favor the latest version (currently 2.2) of
|
110
|
+
the mainline Ruby implementation, potentially sacrificing
|
111
|
+
performance on older Rubies.
|
112
|
+
|
113
|
+
* Some internal, undocumented features and APIs used by
|
114
|
+
derivative servers are gone; removing bloat and slightly lowering
|
115
|
+
memory use. We have never and will never endorse the use of any
|
116
|
+
applications or middleware with a dependency on unicorn,
|
117
|
+
applications should be written for Rack instead.
|
118
|
+
Note: Rainbows! 5.0 will be released next week or so to be
|
119
|
+
compatible with unicorn 5.x
|
120
|
+
|
121
|
+
New features:
|
122
|
+
|
123
|
+
* sd_listen_fds(3) emulation added for systemd compatibility.
|
124
|
+
You may now stop using PID files and other process monitoring
|
125
|
+
software when using systemd.
|
126
|
+
|
127
|
+
* Newly-set TCP socket options are now applied to inherited sockets.
|
128
|
+
|
129
|
+
* Dynamic changes in the application to Rack::Utils::HTTP_STATUS
|
130
|
+
hash is now supported; allowing users to set custom status lines
|
131
|
+
in Rack to be reflected in unicorn. This feature causes a minor
|
132
|
+
performance regression, but is made up for Ruby 2.2 users with
|
133
|
+
other optimizations.
|
134
|
+
|
135
|
+
* The monotonic clock is used under Ruby 2.1+, making the
|
136
|
+
timeout feature immune to system clock changes.
|
137
|
+
|
138
|
+
As unicorn may be used anonymously without registration, the
|
139
|
+
project is committed to supporting anonymous and pseudonymous
|
140
|
+
help requests, contributions and feedback via plain-text mail to:
|
141
|
+
|
142
|
+
unicorn-public@bogomips.org
|
143
|
+
|
144
|
+
The mail submission port (587) is open to those behind firewalls
|
145
|
+
and allows access via Tor and anonymous remailers.
|
146
|
+
Archives are accessible via: http://bogomips.org/unicorn-public/
|
147
|
+
and mirrored to various other places, so you do not need to use
|
148
|
+
a valid address when posting.
|
149
|
+
|
150
|
+
Finally, rest assured the core design of unicorn will never change.
|
151
|
+
It will never use new-fangled things like threads, kqueue or epoll;
|
152
|
+
but will always remain a preforking server serving one client
|
153
|
+
per-process.
|
154
|
+
|
155
|
+
[1] http://mid.gmane.org/20090211230457.GB22926@dcvr.yhbt.net
|
156
|
+
[2] this would've been like, totally gnarly in the 80s!
|
157
|
+
|
1
158
|
=== unicorn 5.0.0.pre2 - another prerelease! / 2015-07-06 21:37 UTC
|
2
159
|
|
3
160
|
There is a minor TCP socket options are now applied to inherited
|
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
|
@@ -27,9 +27,6 @@ both the the request and response in between unicorn and slow clients.
|
|
27
27
|
all run within their own isolated address space and only serve one
|
28
28
|
client at a time for maximum robustness.
|
29
29
|
|
30
|
-
* Supports all Rack applications, along with pre-Rack versions of
|
31
|
-
Ruby on Rails via a Rack wrapper.
|
32
|
-
|
33
30
|
* Builtin reopening of all log files in your application via
|
34
31
|
USR1 signal. This allows logrotate to rotate files atomically and
|
35
32
|
quickly via rename instead of the racy and slow copytruncate method.
|
@@ -54,13 +51,11 @@ both the the request and response in between unicorn and slow clients.
|
|
54
51
|
|
55
52
|
* Simple and easy Ruby DSL for configuration.
|
56
53
|
|
57
|
-
* Decodes chunked
|
58
|
-
notification to be implemented as well as being able to tunnel
|
59
|
-
arbitrary stream-based protocols over HTTP.
|
54
|
+
* Decodes chunked requests on-the-fly.
|
60
55
|
|
61
56
|
== License
|
62
57
|
|
63
|
-
unicorn is copyright 2009 by all contributors (see logs in git).
|
58
|
+
unicorn is copyright 2009-2016 by all contributors (see logs in git).
|
64
59
|
It is based on Mongrel 1.1.5.
|
65
60
|
Mongrel is copyright 2007 Zed A. Shaw and contributors.
|
66
61
|
|
@@ -68,7 +63,7 @@ unicorn is licensed under (your choice) of the GPLv2 or later
|
|
68
63
|
(GPLv3+ preferred), or Ruby (1.8)-specific terms.
|
69
64
|
See the included LICENSE file for details.
|
70
65
|
|
71
|
-
unicorn is 100% Free Software.
|
66
|
+
unicorn is 100% Free Software (including all development tools used).
|
72
67
|
|
73
68
|
== Install
|
74
69
|
|
@@ -85,10 +80,9 @@ You can get the latest source via git from the following locations
|
|
85
80
|
git://bogomips.org/unicorn.git
|
86
81
|
git://repo.or.cz/unicorn.git (mirror)
|
87
82
|
|
88
|
-
You may browse the code from the web
|
89
|
-
tarballs here:
|
83
|
+
You may browse the code from the web:
|
90
84
|
|
91
|
-
* http://bogomips.org/unicorn.git
|
85
|
+
* http://bogomips.org/unicorn.git
|
92
86
|
* http://repo.or.cz/w/unicorn.git (gitweb)
|
93
87
|
|
94
88
|
See the HACKING guide on how to contribute and build prerelease gems
|
@@ -102,12 +96,6 @@ In APP_ROOT, run:
|
|
102
96
|
|
103
97
|
unicorn
|
104
98
|
|
105
|
-
=== Ancient Rails 1.2 - 2.x versions
|
106
|
-
|
107
|
-
In RAILS_ROOT, run:
|
108
|
-
|
109
|
-
unicorn_rails
|
110
|
-
|
111
99
|
unicorn will bind to all interfaces on TCP port 8080 by default.
|
112
100
|
You may use the +--listen/-l+ switch to bind to a different
|
113
101
|
address:port or a UNIX socket.
|
data/Sandbox
CHANGED
@@ -63,9 +63,9 @@ before_exec hook as illustrated by https://gist.github.com/534668
|
|
63
63
|
=== Ruby 2.0.0 close-on-exec and SIGUSR2 incompatibility
|
64
64
|
|
65
65
|
Ruby 2.0.0 enforces FD_CLOEXEC on file descriptors by default. unicorn
|
66
|
-
has been prepared for this behavior since unicorn 4.1.0,
|
67
|
-
|
68
|
-
|
66
|
+
has been prepared for this behavior since unicorn 4.1.0, and bundler
|
67
|
+
needs the "--keep-file-descriptors" option for "bundle exec":
|
68
|
+
http://bundler.io/man/bundle-exec.1.html
|
69
69
|
|
70
70
|
== Isolate
|
71
71
|
|
data/examples/unicorn@.service
CHANGED
@@ -11,6 +11,8 @@ Wants = unicorn.socket
|
|
11
11
|
After = unicorn.socket
|
12
12
|
|
13
13
|
[Service]
|
14
|
+
# bundler users must use the "--keep-file-descriptors" switch, here:
|
15
|
+
# ExecStart = bundle exec --keep-file-descriptors unicorn -c ...
|
14
16
|
ExecStart = /usr/bin/unicorn -c /path/to/unicorn.conf.rb /path/to/config.ru
|
15
17
|
Sockets = unicorn.socket
|
16
18
|
KillSignal = SIGQUIT
|
@@ -3437,11 +3437,31 @@ post_exec: /* "_out:" also goes here */
|
|
3437
3437
|
assert(hp->offset <= len && "offset longer than length");
|
3438
3438
|
}
|
3439
3439
|
|
3440
|
+
static void hp_mark(void *ptr)
|
3441
|
+
{
|
3442
|
+
struct http_parser *hp = ptr;
|
3443
|
+
|
3444
|
+
rb_gc_mark(hp->buf);
|
3445
|
+
rb_gc_mark(hp->env);
|
3446
|
+
rb_gc_mark(hp->cont);
|
3447
|
+
}
|
3448
|
+
|
3449
|
+
static size_t hp_memsize(const void *ptr)
|
3450
|
+
{
|
3451
|
+
return sizeof(struct http_parser);
|
3452
|
+
}
|
3453
|
+
|
3454
|
+
static const rb_data_type_t hp_type = {
|
3455
|
+
"unicorn_http",
|
3456
|
+
{ hp_mark, RUBY_TYPED_DEFAULT_FREE, hp_memsize, /* reserved */ },
|
3457
|
+
/* parent, data, [ flags ] */
|
3458
|
+
};
|
3459
|
+
|
3440
3460
|
static struct http_parser *data_get(VALUE self)
|
3441
3461
|
{
|
3442
3462
|
struct http_parser *hp;
|
3443
3463
|
|
3444
|
-
|
3464
|
+
TypedData_Get_Struct(self, struct http_parser, &hp_type, hp);
|
3445
3465
|
assert(hp && "failed to extract http_parser struct");
|
3446
3466
|
return hp;
|
3447
3467
|
}
|
@@ -3547,21 +3567,12 @@ static void finalize_header(struct http_parser *hp)
|
|
3547
3567
|
rb_hash_aset(hp->env, g_query_string, rb_str_new(NULL, 0));
|
3548
3568
|
}
|
3549
3569
|
|
3550
|
-
static void hp_mark(void *ptr)
|
3551
|
-
{
|
3552
|
-
struct http_parser *hp = ptr;
|
3553
|
-
|
3554
|
-
rb_gc_mark(hp->buf);
|
3555
|
-
rb_gc_mark(hp->env);
|
3556
|
-
rb_gc_mark(hp->cont);
|
3557
|
-
}
|
3558
|
-
|
3559
3570
|
static VALUE HttpParser_alloc(VALUE klass)
|
3560
3571
|
{
|
3561
3572
|
struct http_parser *hp;
|
3562
|
-
return Data_Make_Struct(klass, struct http_parser, hp_mark, -1, hp);
|
3563
|
-
}
|
3564
3573
|
|
3574
|
+
return TypedData_Make_Struct(klass, struct http_parser, &hp_type, hp);
|
3575
|
+
}
|
3565
3576
|
|
3566
3577
|
/**
|
3567
3578
|
* call-seq:
|
@@ -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,
|
data/lib/unicorn/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Unicorn::Const::UNICORN_VERSION = '5.0
|
1
|
+
Unicorn::Const::UNICORN_VERSION = '5.1.0'
|
data/man/man1/unicorn.1
CHANGED
@@ -205,8 +205,6 @@ Users relying on this feature do not need to specify a listen socket in
|
|
205
205
|
the unicorn config file.
|
206
206
|
.SH SEE ALSO
|
207
207
|
.IP \[bu] 2
|
208
|
-
unicorn_rails(1)
|
209
|
-
.IP \[bu] 2
|
210
208
|
\f[I]Rack::Builder\f[] ri/RDoc
|
211
209
|
.IP \[bu] 2
|
212
210
|
\f[I]Unicorn::Configurator\f[] ri/RDoc
|
data/man/man1/unicorn_rails.1
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
.TH UNICORN_RAILS 1 "September 17, 2009" "Unicorn User Manual"
|
2
2
|
.SH NAME
|
3
3
|
.PP
|
4
|
-
unicorn_rails -
|
5
|
-
server
|
4
|
+
unicorn_rails - unicorn launcher for Rails 1.x and 2.x users
|
6
5
|
.SH SYNOPSIS
|
7
6
|
.PP
|
8
7
|
unicorn_rails [-c CONFIG_FILE] [-E RAILS_ENV] [-D] [RACKUP_FILE]
|
@@ -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
|
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-04-01 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
|
@@ -115,8 +115,6 @@ extra_rdoc_files:
|
|
115
115
|
- lib/unicorn/util.rb
|
116
116
|
- lib/unicorn/oob_gc.rb
|
117
117
|
- lib/unicorn/worker.rb
|
118
|
-
- unicorn_1
|
119
|
-
- unicorn_rails_1
|
120
118
|
- ISSUES
|
121
119
|
- Sandbox
|
122
120
|
- Links
|
@@ -278,8 +276,6 @@ files:
|
|
278
276
|
- test/unit/test_upload.rb
|
279
277
|
- test/unit/test_util.rb
|
280
278
|
- unicorn.gemspec
|
281
|
-
- unicorn_1
|
282
|
-
- unicorn_rails_1
|
283
279
|
homepage: http://unicorn.bogomips.org/
|
284
280
|
licenses:
|
285
281
|
- GPL-2.0+
|
@@ -301,7 +297,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
301
297
|
version: '0'
|
302
298
|
requirements: []
|
303
299
|
rubyforge_project:
|
304
|
-
rubygems_version: 2.
|
300
|
+
rubygems_version: 2.6.2
|
305
301
|
signing_key:
|
306
302
|
specification_version: 4
|
307
303
|
summary: Rack HTTP server for fast clients and Unix
|
data/unicorn_1
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
olddoc_placeholder
|
data/unicorn_rails_1
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
olddoc_placeholder
|