unicorn 5.0.0.pre2 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Application_Timeouts +3 -3
- data/DESIGN +2 -4
- data/Documentation/unicorn.1.txt +6 -3
- data/GIT-VERSION-GEN +1 -1
- data/ISSUES +19 -28
- data/KNOWN_ISSUES +7 -7
- data/Links +13 -17
- data/PHILOSOPHY +0 -6
- data/README +21 -16
- data/Sandbox +1 -1
- data/TUNING +5 -5
- data/examples/nginx.conf +10 -11
- data/examples/unicorn.conf.rb +1 -4
- data/ext/unicorn_http/unicorn_http.rl +1 -1
- data/lib/unicorn.rb +3 -3
- data/lib/unicorn/configurator.rb +15 -14
- data/lib/unicorn/http_server.rb +5 -5
- data/lib/unicorn/socket_helper.rb +3 -5
- data/lib/unicorn/stream_input.rb +3 -3
- data/lib/unicorn/util.rb +1 -1
- data/lib/unicorn/worker.rb +2 -2
- data/test/exec/test_exec.rb +37 -9
- data/unicorn.gemspec +10 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0f63df97befc889520fdfd69aa7e8acc52e6a98
|
4
|
+
data.tar.gz: a09d9d5c31dffbb73b43675496545ab22a67af2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01bcc9ba08ff53c1649de5939d8c3b8ec96d6bfc6bf4b95c1e50d4017c316eaacfd332ddf90409c2225298e4540cbaddc167d12c96c960bf78934691978167cb
|
7
|
+
data.tar.gz: 9601aa0700f3597941f38740274fcba8cd7c5835741e64611dbace52609be533f78328f6336ce5813ed0e96a853f8946d19b55321880acd07bcdd3f5048b2d75
|
data/Application_Timeouts
CHANGED
@@ -4,10 +4,10 @@ This article focuses on _application_ setup for Rack applications, but
|
|
4
4
|
can be expanded to all applications that connect to external resources
|
5
5
|
and expect short response times.
|
6
6
|
|
7
|
-
This article is not specific to
|
7
|
+
This article is not specific to unicorn, but exists to discourage
|
8
8
|
the overuse of the built-in
|
9
9
|
{timeout}[link:Unicorn/Configurator.html#method-i-timeout] directive
|
10
|
-
in
|
10
|
+
in unicorn.
|
11
11
|
|
12
12
|
== ALL External Resources Are Considered Unreliable
|
13
13
|
|
@@ -71,7 +71,7 @@ handle network/server failures.
|
|
71
71
|
== The Last Line Of Defense
|
72
72
|
|
73
73
|
The {timeout}[link:Unicorn/Configurator.html#method-i-timeout] mechanism
|
74
|
-
in
|
74
|
+
in unicorn is an extreme solution that should be avoided whenever
|
75
75
|
possible. It will help catch bugs in your application where and when
|
76
76
|
your application forgets to use timeouts, but it is expensive as it
|
77
77
|
kills and respawns a worker process.
|
data/DESIGN
CHANGED
@@ -7,9 +7,7 @@
|
|
7
7
|
all clients down, just one. Only UNIX-like systems supporting
|
8
8
|
fork() and file descriptor inheritance are supported.
|
9
9
|
|
10
|
-
* The Ragel+C HTTP parser is taken from Mongrel.
|
11
|
-
only non-Ruby part and there are no plans to add any more
|
12
|
-
non-Ruby components.
|
10
|
+
* The Ragel+C HTTP parser is taken from Mongrel.
|
13
11
|
|
14
12
|
* All HTTP parsing and I/O is done much like Mongrel:
|
15
13
|
1. read/parse HTTP request headers in full
|
@@ -31,7 +29,7 @@
|
|
31
29
|
* One master process spawns and reaps worker processes. The
|
32
30
|
Rack application itself is called only within the worker process (but
|
33
31
|
can be loaded within the master). A copy-on-write friendly garbage
|
34
|
-
collector like the one found in Ruby 2.0.
|
32
|
+
collector like the one found in mainline Ruby 2.0.0 and later
|
35
33
|
can be used to minimize memory usage along with the "preload_app true"
|
36
34
|
directive (see Unicorn::Configurator).
|
37
35
|
|
data/Documentation/unicorn.1.txt
CHANGED
@@ -166,9 +166,12 @@ variable internally when doing transparent upgrades.
|
|
166
166
|
UNICORN_FD is a comma-delimited list of one or more file descriptors
|
167
167
|
used to implement USR2 upgrades. Init systems may bind listen sockets
|
168
168
|
itself and spawn unicorn with UNICORN_FD set to the file descriptor
|
169
|
-
numbers of the listen socket(s).
|
170
|
-
|
171
|
-
|
169
|
+
numbers of the listen socket(s).
|
170
|
+
|
171
|
+
As of unicorn 5.0, LISTEN_PID and LISTEN_FDS are used for socket
|
172
|
+
activation as documented in the sd_listen_fds(3) manpage. Users
|
173
|
+
relying on this feature do not need to specify a listen socket in
|
174
|
+
the unicorn config file.
|
172
175
|
|
173
176
|
# SEE ALSO
|
174
177
|
|
data/GIT-VERSION-GEN
CHANGED
data/ISSUES
CHANGED
@@ -9,8 +9,10 @@ submit patches and/or obtain support after you have searched the
|
|
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
|
12
|
-
* Do not send HTML mail, it will be flagged as spam
|
12
|
+
* Do not send HTML mail or images, it will be flagged as spam
|
13
13
|
* Anonymous and pseudonymous messages will always be welcome.
|
14
|
+
* The email submission port (587) is enabled on the bogomips.org MX:
|
15
|
+
http://bogomips.org/unicorn-public/20141004232241.GA23908@dcvr.yhbt.net/t/
|
14
16
|
|
15
17
|
If your issue is of a sensitive nature or you're just shy in public,
|
16
18
|
then feel free to email us privately at mailto:unicorn@bogomips.org
|
@@ -63,39 +65,28 @@ document distributed with git) on guidelines for patch submission.
|
|
63
65
|
|
64
66
|
* public: mailto:unicorn-public@bogomips.org
|
65
67
|
* private: mailto:unicorn@bogomips.org
|
68
|
+
* nntp://news.gmane.org/gmane.comp.lang.ruby.unicorn.general
|
69
|
+
* nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
|
70
|
+
* http://bogomips.org/unicorn-public/
|
66
71
|
|
67
72
|
We operate a {public-inbox}[http://public-inbox.org/] which
|
68
|
-
feeds the mailing list.
|
69
|
-
|
70
|
-
to mailto:unicorn-public+subscribe@bogomips.org
|
73
|
+
feeds the mailing list. Subscription is optional, so Cc:
|
74
|
+
all participants.
|
71
75
|
|
72
|
-
|
73
|
-
fashion to tools such as slrnpull, fetchmail, or getmail. ssoma
|
74
|
-
subscription instructions:
|
76
|
+
You can follow along via NNTP:
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
+
nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
|
79
|
+
nntp://news.gmane.org/gmane.comp.lang.ruby.unicorn.general
|
78
80
|
|
79
|
-
|
80
|
-
# ssoma will not touch existing messages)
|
81
|
-
# If you prefer mbox, use mbox:/path/to/mbox as the last argument
|
82
|
-
# You may also use imap://$MAILSERVER/INBOX for an IMAP account
|
83
|
-
# or imaps:// for an IMAPS account, as well.
|
84
|
-
ssoma add $LISTNAME $URL maildir:/path/to/maildir
|
81
|
+
Or Atom feeds:
|
85
82
|
|
86
|
-
|
87
|
-
mutt -f /path/to/maildir # (or /path/to/mbox)
|
83
|
+
http://bogomips.org/unicorn-public/new.atom
|
88
84
|
|
89
|
-
|
90
|
-
|
85
|
+
The HTML archives at http://bogomips.org/unicorn-public/
|
86
|
+
also has links to per-thread Atom feeds and downloadable
|
87
|
+
mboxes.
|
91
88
|
|
92
|
-
|
93
|
-
# this does not affect ssoma functionality at all
|
89
|
+
You may also subscribe via plain-text email:
|
94
90
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
# You may wish to sync in your cronjob
|
99
|
-
ssoma sync --cron
|
100
|
-
|
101
|
-
HTML archives are available here: http://bogomips.org/unicorn-public/
|
91
|
+
mailto:unicorn-public+subscribe@bogomips.org
|
92
|
+
(and confirming the auto-reply)
|
data/KNOWN_ISSUES
CHANGED
@@ -13,7 +13,7 @@ acceptable solution. Those issues are documented here.
|
|
13
13
|
|
14
14
|
* PRNGs (pseudo-random number generators) loaded before forking
|
15
15
|
(e.g. "preload_app true") may need to have their internal state
|
16
|
-
reset in the after_fork hook. Starting with
|
16
|
+
reset in the after_fork hook. Starting with unicorn 3.6.1, we
|
17
17
|
have builtin workarounds for Kernel#rand and OpenSSL::Random users,
|
18
18
|
but applications may use other PRNGs.
|
19
19
|
|
@@ -36,13 +36,13 @@ acceptable solution. Those issues are documented here.
|
|
36
36
|
|
37
37
|
* Under some versions of Ruby 1.8, it is necessary to call +srand+ in an
|
38
38
|
after_fork hook to get correct random number generation. We have a builtin
|
39
|
-
workaround for this starting with
|
39
|
+
workaround for this starting with unicorn 3.6.1
|
40
40
|
|
41
41
|
See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/36450
|
42
42
|
|
43
43
|
* On Ruby 1.8 prior to Ruby 1.8.7-p248, *BSD platforms have a broken
|
44
44
|
stdio that causes failure for file uploads larger than 112K. Upgrade
|
45
|
-
your version of Ruby or continue using
|
45
|
+
your version of Ruby or continue using unicorn 1.x/3.4.x.
|
46
46
|
|
47
47
|
* Under Ruby 1.9.1, methods like Array#shuffle and Array#sample will
|
48
48
|
segfault if called after forking. Upgrade to Ruby 1.9.2 or call
|
@@ -53,12 +53,12 @@ acceptable solution. Those issues are documented here.
|
|
53
53
|
|
54
54
|
* Rails 2.3.2 bundles its own version of Rack. This may cause subtle
|
55
55
|
bugs when simultaneously loaded with the system-wide Rack Rubygem
|
56
|
-
which
|
56
|
+
which unicorn depends on. Upgrading to Rails 2.3.4 (or later) is
|
57
57
|
strongly recommended for all Rails 2.3.x users for this (and security
|
58
58
|
reasons). Rails 2.2.x series (or before) did not bundle Rack and are
|
59
59
|
should be unnaffected. If there is any reason which forces your
|
60
60
|
application to use Rails 2.3.2 and you have no other choice, then
|
61
|
-
you may edit your
|
61
|
+
you may edit your unicorn gemspec and remove the Rack dependency.
|
62
62
|
|
63
63
|
ref: http://mid.gmane.org/20091014221552.GA30624@dcvr.yhbt.net
|
64
64
|
Note: the workaround described in the article above only made
|
@@ -71,9 +71,9 @@ acceptable solution. Those issues are documented here.
|
|
71
71
|
set :env, :production
|
72
72
|
set :run, false
|
73
73
|
Since this is no longer an issue with Sinatra 0.9.x apps, this will not be
|
74
|
-
fixed on our end. Since
|
74
|
+
fixed on our end. Since unicorn is itself the application launcher, the
|
75
75
|
at_exit handler used in old Sinatra always caused Mongrel to be launched
|
76
|
-
whenever a
|
76
|
+
whenever a unicorn worker was about to exit.
|
77
77
|
|
78
78
|
Also remember we're capable of replacing the running binary without dropping
|
79
79
|
any connections regardless of framework :)
|
data/Links
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
= Related Projects
|
2
2
|
|
3
|
-
If you're interested in
|
3
|
+
If you're interested in unicorn, you may be interested in some of the projects
|
4
4
|
listed below. If you have any links to add/change/remove, please tell us at
|
5
5
|
mailto:unicorn-public@bogomips.org!
|
6
6
|
|
7
7
|
== Disclaimer
|
8
8
|
|
9
|
-
The
|
10
|
-
Furthermore, the
|
9
|
+
The unicorn project is not responsible for the content in these links.
|
10
|
+
Furthermore, the unicorn project has never, does not and will never endorse:
|
11
11
|
|
12
12
|
* any for-profit entities or services
|
13
13
|
* any non-{Free Software}[http://www.gnu.org/philosophy/free-sw.html]
|
@@ -15,13 +15,13 @@ Furthermore, the \Unicorn project has never, does not and will never endorse:
|
|
15
15
|
The existence of these links does not imply endorsement of any entities
|
16
16
|
or services behind them.
|
17
17
|
|
18
|
-
=== For use with
|
18
|
+
=== For use with unicorn
|
19
19
|
|
20
20
|
* {Bluepill}[https://github.com/arya/bluepill] -
|
21
21
|
a simple process monitoring tool written in Ruby
|
22
22
|
|
23
23
|
* {golden_brindle}[https://github.com/simonoff/golden_brindle] - tool to
|
24
|
-
manage multiple
|
24
|
+
manage multiple unicorn instances/applications on a single server
|
25
25
|
|
26
26
|
* {raindrops}[http://raindrops.bogomips.org/] - real-time stats for
|
27
27
|
preforking Rack servers
|
@@ -29,27 +29,23 @@ or services behind them.
|
|
29
29
|
* {UnXF}[http://bogomips.org/unxf/] Un-X-Forward* the Rack environment,
|
30
30
|
useful since unicorn is designed to be deployed behind a reverse proxy.
|
31
31
|
|
32
|
-
===
|
32
|
+
=== unicorn is written to work with
|
33
33
|
|
34
34
|
* {Rack}[http://rack.github.io/] - a minimal interface between webservers
|
35
35
|
supporting Ruby and Ruby frameworks
|
36
36
|
|
37
37
|
* {Ruby}[https://www.ruby-lang.org/en/] - the programming language of
|
38
|
-
Rack and
|
38
|
+
Rack and unicorn
|
39
39
|
|
40
|
-
* {nginx}[http://nginx.org/]
|
41
|
-
|
42
|
-
* {kgio}[http://bogomips.org/kgio/] - the I/O library written for \Unicorn
|
40
|
+
* {nginx}[http://nginx.org/] (Free versions) -
|
41
|
+
the reverse proxy for use with unicorn
|
43
42
|
|
44
43
|
=== Derivatives
|
45
44
|
|
46
|
-
* {Green Unicorn}[http://gunicorn.org/] - a Python version of
|
47
|
-
|
48
|
-
* {Rainbows!}[http://rainbows.bogomips.org/] - \Unicorn for sleepy
|
49
|
-
apps and slow clients (historical).
|
45
|
+
* {Green Unicorn}[http://gunicorn.org/] - a Python version of unicorn
|
50
46
|
|
51
|
-
* {
|
52
|
-
|
47
|
+
* {Starman}[http://search.cpan.org/dist/Starman/] - Plack/PSGI version
|
48
|
+
of unicorn
|
53
49
|
|
54
50
|
=== Prior Work
|
55
51
|
|
@@ -57,4 +53,4 @@ or services behind them.
|
|
57
53
|
unicorn is based on
|
58
54
|
|
59
55
|
* {david}[http://bogomips.org/david.git] - a tool to explain why you need
|
60
|
-
nginx in front of
|
56
|
+
nginx in front of unicorn
|
data/PHILOSOPHY
CHANGED
@@ -137,9 +137,3 @@ unicorn is highly inefficient for Comet/reverse-HTTP/push applications
|
|
137
137
|
where the HTTP connection spends a large amount of time idle.
|
138
138
|
Nevertheless, the ease of troubleshooting, debugging, and management of
|
139
139
|
unicorn may still outweigh the drawbacks for these applications.
|
140
|
-
|
141
|
-
The {Rainbows!}[http://rainbows.bogomips.org/] aims to fill the gap for
|
142
|
-
odd corner cases where the nginx + unicorn combination is not enough.
|
143
|
-
While Rainbows! management/administration is largely identical to
|
144
|
-
unicorn, Rainbows! is far more ambitious and has seen little real-world
|
145
|
-
usage.
|
data/README
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
=
|
1
|
+
= unicorn: Rack HTTP server for fast clients and Unix
|
2
2
|
|
3
|
-
|
3
|
+
unicorn is an HTTP server for Rack applications designed to only serve
|
4
4
|
fast clients on low-latency, high-bandwidth connections and take
|
5
5
|
advantage of features in Unix/Unix-like kernels. Slow clients should
|
6
6
|
only be served by placing a reverse proxy capable of fully buffering
|
7
|
-
both the the request and response in between
|
7
|
+
both the the request and response in between unicorn and slow clients.
|
8
8
|
|
9
9
|
== Features
|
10
10
|
|
@@ -15,9 +15,9 @@ both the the request and response in between \Unicorn and slow clients.
|
|
15
15
|
* Compatible with Ruby 1.9.3 and later.
|
16
16
|
unicorn 4.8.x will remain supported for Ruby 1.8 users.
|
17
17
|
|
18
|
-
* Process management:
|
18
|
+
* Process management: unicorn will reap and restart workers that
|
19
19
|
die from broken apps. There is no need to manage multiple processes
|
20
|
-
or ports yourself.
|
20
|
+
or ports yourself. unicorn can spawn and manage any number of
|
21
21
|
worker processes you choose to scale to your backend.
|
22
22
|
|
23
23
|
* Load balancing is done entirely by the operating system kernel.
|
@@ -33,11 +33,11 @@ both the the request and response in between \Unicorn and slow clients.
|
|
33
33
|
* Builtin reopening of all log files in your application via
|
34
34
|
USR1 signal. This allows logrotate to rotate files atomically and
|
35
35
|
quickly via rename instead of the racy and slow copytruncate method.
|
36
|
-
|
36
|
+
unicorn also takes steps to ensure multi-line log entries from one
|
37
37
|
request all stay within the same file.
|
38
38
|
|
39
39
|
* nginx-style binary upgrades without losing connections.
|
40
|
-
You can upgrade
|
40
|
+
You can upgrade unicorn, your entire application, libraries
|
41
41
|
and even your Ruby interpreter without dropping clients.
|
42
42
|
|
43
43
|
* before_fork and after_fork hooks in case your application
|
@@ -60,15 +60,15 @@ both the the request and response in between \Unicorn and slow clients.
|
|
60
60
|
|
61
61
|
== License
|
62
62
|
|
63
|
-
|
63
|
+
unicorn is copyright 2009 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
|
|
67
|
-
|
67
|
+
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
|
-
|
71
|
+
unicorn is 100% Free Software.
|
72
72
|
|
73
73
|
== Install
|
74
74
|
|
@@ -108,17 +108,17 @@ In RAILS_ROOT, run:
|
|
108
108
|
|
109
109
|
unicorn_rails
|
110
110
|
|
111
|
-
|
111
|
+
unicorn will bind to all interfaces on TCP port 8080 by default.
|
112
112
|
You may use the +--listen/-l+ switch to bind to a different
|
113
113
|
address:port or a UNIX socket.
|
114
114
|
|
115
115
|
=== Configuration File(s)
|
116
116
|
|
117
|
-
|
117
|
+
unicorn will look for the config.ru file used by rackup in APP_ROOT.
|
118
118
|
|
119
|
-
For deployments, it can use a config file for
|
119
|
+
For deployments, it can use a config file for unicorn-specific options
|
120
120
|
specified by the +--config-file/-c+ command-line switch. See
|
121
|
-
Unicorn::Configurator for the syntax of the
|
121
|
+
Unicorn::Configurator for the syntax of the unicorn-specific options.
|
122
122
|
The default settings are designed for maximum out-of-the-box
|
123
123
|
compatibility with existing applications.
|
124
124
|
|
@@ -130,7 +130,7 @@ supported. Run `unicorn -h` to see command-line options.
|
|
130
130
|
There is NO WARRANTY whatsoever if anything goes wrong, but
|
131
131
|
{let us know}[link:ISSUES.html] and we'll try our best to fix it.
|
132
132
|
|
133
|
-
|
133
|
+
unicorn is designed to only serve fast clients either on the local host
|
134
134
|
or a fast LAN. See the PHILOSOPHY and DESIGN documents for more details
|
135
135
|
regarding this.
|
136
136
|
|
@@ -140,6 +140,11 @@ All feedback (bug reports, user/development dicussion, patches, pull
|
|
140
140
|
requests) go to the mailing list/newsgroup. See the ISSUES document for
|
141
141
|
information on the {mailing list}[mailto:unicorn-public@bogomips.org].
|
142
142
|
|
143
|
-
|
143
|
+
The mailing list is archived at http://bogomips.org/unicorn-public/
|
144
|
+
Read-only NNTP access is available at:
|
145
|
+
nntp://news.public-inbox.org/inbox.comp.lang.ruby.unicorn and
|
146
|
+
nntp://news.gmane.org/gmane.comp.lang.ruby.unicorn.general
|
147
|
+
|
148
|
+
For the latest on unicorn releases, you may also finger us at
|
144
149
|
unicorn@bogomips.org or check our NEWS page (and subscribe to our Atom
|
145
150
|
feed).
|
data/Sandbox
CHANGED
data/TUNING
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
= Tuning
|
1
|
+
= Tuning unicorn
|
2
2
|
|
3
|
-
|
3
|
+
unicorn performance is generally as good as a (mostly) Ruby web server
|
4
4
|
can provide. Most often the performance bottleneck is in the web
|
5
5
|
application running on Unicorn rather than Unicorn itself.
|
6
6
|
|
7
|
-
==
|
7
|
+
== unicorn Configuration
|
8
8
|
|
9
9
|
See Unicorn::Configurator for details on the config file format.
|
10
10
|
+worker_processes+ is the most-commonly needed tuning parameter.
|
@@ -14,7 +14,7 @@ See Unicorn::Configurator for details on the config file format.
|
|
14
14
|
* worker_processes should be scaled to the number of processes your
|
15
15
|
backend system(s) can support. DO NOT scale it to the number of
|
16
16
|
external network clients your application expects to be serving.
|
17
|
-
|
17
|
+
unicorn is NOT for serving slow clients, that is the job of nginx.
|
18
18
|
|
19
19
|
* worker_processes should be *at* *least* the number of CPU cores on
|
20
20
|
a dedicated server (unless you do not have enough memory).
|
@@ -58,7 +58,7 @@ See Unicorn::Configurator for details on the config file format.
|
|
58
58
|
* UNIX domain sockets are slightly faster than TCP sockets, but only
|
59
59
|
work if nginx is on the same machine.
|
60
60
|
|
61
|
-
== Other
|
61
|
+
== Other unicorn settings
|
62
62
|
|
63
63
|
* Setting "preload_app true" can allow copy-on-write-friendly GC to
|
64
64
|
be used to save memory. It will probably not work out of the box with
|
data/examples/nginx.conf
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# This is example contains the bare mininum to get nginx going with
|
2
|
-
#
|
2
|
+
# unicorn servers. Generally these configuration settings
|
3
3
|
# are applicable to other HTTP application servers (and not just Ruby
|
4
4
|
# ones), so if you have one working well for proxying another app
|
5
5
|
# server, feel free to continue using it.
|
@@ -44,8 +44,8 @@ http {
|
|
44
44
|
# click tracking!
|
45
45
|
access_log /path/to/nginx.access.log combined;
|
46
46
|
|
47
|
-
# you generally want to serve static files with nginx since
|
48
|
-
#
|
47
|
+
# you generally want to serve static files with nginx since
|
48
|
+
# unicorn is not and will never be optimized for it
|
49
49
|
sendfile on;
|
50
50
|
|
51
51
|
tcp_nopush on; # off may be better for *some* Comet/long-poll stuff
|
@@ -67,10 +67,10 @@ http {
|
|
67
67
|
text/javascript application/x-javascript
|
68
68
|
application/atom+xml;
|
69
69
|
|
70
|
-
# this can be any application server, not just
|
70
|
+
# this can be any application server, not just unicorn
|
71
71
|
upstream app_server {
|
72
72
|
# fail_timeout=0 means we always retry an upstream even if it failed
|
73
|
-
# to return a good HTTP response (in case the
|
73
|
+
# to return a good HTTP response (in case the unicorn master nukes a
|
74
74
|
# single worker for timing out).
|
75
75
|
|
76
76
|
# for UNIX domain socket setups:
|
@@ -132,12 +132,11 @@ http {
|
|
132
132
|
# redirects, we set the Host: header above already.
|
133
133
|
proxy_redirect off;
|
134
134
|
|
135
|
-
# set
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
140
|
-
# client can become a bottleneck of Unicorn.
|
135
|
+
# It's also safe to set if you're using only serving fast clients
|
136
|
+
# with unicorn + nginx, but not slow clients. You normally want
|
137
|
+
# nginx to buffer responses to slow clients, even with Rails 3.1
|
138
|
+
# streaming because otherwise a slow client can become a bottleneck
|
139
|
+
# of unicorn.
|
141
140
|
#
|
142
141
|
# The Rack application may also set "X-Accel-Buffering (yes|no)"
|
143
142
|
# in the response headers do disable/enable buffering on a
|
data/examples/unicorn.conf.rb
CHANGED
@@ -40,11 +40,8 @@ pid "/path/to/app/shared/pids/unicorn.pid"
|
|
40
40
|
stderr_path "/path/to/app/shared/log/unicorn.stderr.log"
|
41
41
|
stdout_path "/path/to/app/shared/log/unicorn.stdout.log"
|
42
42
|
|
43
|
-
# combine Ruby 2.0.
|
44
|
-
# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
|
43
|
+
# combine Ruby 2.0.0+ with "preload_app true" for memory savings
|
45
44
|
preload_app true
|
46
|
-
GC.respond_to?(:copy_on_write_friendly=) and
|
47
|
-
GC.copy_on_write_friendly = true
|
48
45
|
|
49
46
|
# Enable this flag to have unicorn test client connections by writing the
|
50
47
|
# beginning of the HTTP headers before calling the application. This
|
@@ -38,7 +38,7 @@ static VALUE set_maxhdrlen(VALUE self, VALUE len)
|
|
38
38
|
return UINT2NUM(MAX_HEADER_LEN = NUM2UINT(len));
|
39
39
|
}
|
40
40
|
|
41
|
-
/* keep this small for
|
41
|
+
/* keep this small for other servers (e.g. yahns) since every client has one */
|
42
42
|
struct http_parser {
|
43
43
|
int cs; /* Ragel internal state */
|
44
44
|
unsigned int flags;
|
data/lib/unicorn.rb
CHANGED
@@ -10,10 +10,10 @@ require 'kgio'
|
|
10
10
|
# enough functionality to service web application requests fast as possible.
|
11
11
|
# :startdoc:
|
12
12
|
|
13
|
-
#
|
14
|
-
# internals are subject to change.
|
13
|
+
# unicorn exposes very little of an user-visible API and most of its
|
14
|
+
# internals are subject to change. unicorn is designed to host Rack
|
15
15
|
# applications, so applications should be written against the Rack SPEC
|
16
|
-
# and not
|
16
|
+
# and not unicorn internals.
|
17
17
|
module Unicorn
|
18
18
|
|
19
19
|
# Raised inside TeeInput when a client closes the socket inside the
|
data/lib/unicorn/configurator.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# -*- encoding: binary -*-
|
2
2
|
require 'logger'
|
3
3
|
|
4
|
-
# Implements a simple DSL for configuring a
|
4
|
+
# Implements a simple DSL for configuring a unicorn server.
|
5
5
|
#
|
6
6
|
# See http://unicorn.bogomips.org/examples/unicorn.conf.rb and
|
7
7
|
# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
|
@@ -254,6 +254,11 @@ class Unicorn::Configurator
|
|
254
254
|
#
|
255
255
|
# Default: 1024
|
256
256
|
#
|
257
|
+
# Note: with the Linux kernel, the net.core.somaxconn sysctl defaults
|
258
|
+
# to 128, capping this value to 128. Raising the sysctl allows a
|
259
|
+
# larger backlog (which may not be desirable with multiple,
|
260
|
+
# load-balanced machines).
|
261
|
+
#
|
257
262
|
# [:rcvbuf => bytes, :sndbuf => bytes]
|
258
263
|
#
|
259
264
|
# Maximum receive and send buffer sizes (in bytes) of sockets.
|
@@ -277,20 +282,19 @@ class Unicorn::Configurator
|
|
277
282
|
# Setting this to +true+ can make streaming responses in Rails 3.1
|
278
283
|
# appear more quickly at the cost of slightly higher bandwidth usage.
|
279
284
|
# The effect of this option is most visible if nginx is not used,
|
280
|
-
# but nginx remains highly recommended with
|
285
|
+
# but nginx remains highly recommended with unicorn.
|
281
286
|
#
|
282
287
|
# This has no effect on UNIX sockets.
|
283
288
|
#
|
284
|
-
# Default: +true+ (Nagle's algorithm disabled) in
|
285
|
-
#
|
286
|
-
# 3.x
|
289
|
+
# Default: +true+ (Nagle's algorithm disabled) in unicorn
|
290
|
+
# This defaulted to +false+ in unicorn 3.x
|
287
291
|
#
|
288
292
|
# [:tcp_nopush => true or false]
|
289
293
|
#
|
290
294
|
# Enables/disables TCP_CORK in Linux or TCP_NOPUSH in FreeBSD
|
291
295
|
#
|
292
296
|
# This prevents partial TCP frames from being sent out and reduces
|
293
|
-
# wakeups in nginx if it is on a different machine. Since
|
297
|
+
# wakeups in nginx if it is on a different machine. Since unicorn
|
294
298
|
# is only designed for applications that send the response body
|
295
299
|
# quickly without keepalive, sockets will always be flushed on close
|
296
300
|
# to prevent delays.
|
@@ -298,7 +302,7 @@ class Unicorn::Configurator
|
|
298
302
|
# This has no effect on UNIX sockets.
|
299
303
|
#
|
300
304
|
# Default: +false+
|
301
|
-
# This defaulted to +true+ in
|
305
|
+
# This defaulted to +true+ in unicorn 3.4 - 3.7
|
302
306
|
#
|
303
307
|
# [:ipv6only => true or false]
|
304
308
|
#
|
@@ -382,12 +386,10 @@ class Unicorn::Configurator
|
|
382
386
|
# and +false+ or +nil+ is synonymous for a value of zero.
|
383
387
|
#
|
384
388
|
# A value of +1+ is a good optimization for local networks
|
385
|
-
# and trusted clients.
|
386
|
-
#
|
387
|
-
# denial-of-service attacks. There is no good reason to ever
|
388
|
-
# disable this with a +zero+ value when serving HTTP.
|
389
|
+
# and trusted clients. There is no good reason to ever
|
390
|
+
# disable this with a +zero+ value with unicorn.
|
389
391
|
#
|
390
|
-
# Default: 1
|
392
|
+
# Default: 1
|
391
393
|
#
|
392
394
|
# [:accept_filter => String]
|
393
395
|
#
|
@@ -396,8 +398,7 @@ class Unicorn::Configurator
|
|
396
398
|
# This enables either the "dataready" or (default) "httpready"
|
397
399
|
# accept() filter under FreeBSD. This is intended as an
|
398
400
|
# optimization to reduce context switches with common GET/HEAD
|
399
|
-
# requests.
|
400
|
-
# some protection against certain denial-of-service attacks, too.
|
401
|
+
# requests.
|
401
402
|
#
|
402
403
|
# There is no good reason to change from the default.
|
403
404
|
#
|
data/lib/unicorn/http_server.rb
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
#
|
8
8
|
# Users do not need to know the internals of this class, but reading the
|
9
9
|
# {source}[http://bogomips.org/unicorn.git/tree/lib/unicorn/http_server.rb]
|
10
|
-
# is education for programmers wishing to learn how
|
11
|
-
# See Unicorn::Configurator for information on how to configure
|
10
|
+
# is education for programmers wishing to learn how unicorn works.
|
11
|
+
# See Unicorn::Configurator for information on how to configure unicorn.
|
12
12
|
class Unicorn::HttpServer
|
13
13
|
# :stopdoc:
|
14
14
|
attr_accessor :app, :timeout, :worker_processes,
|
@@ -770,14 +770,14 @@ class Unicorn::HttpServer
|
|
770
770
|
|
771
771
|
# emulate sd_listen_fds() for systemd
|
772
772
|
sd_pid, sd_fds = ENV.values_at('LISTEN_PID', 'LISTEN_FDS')
|
773
|
-
if sd_pid
|
773
|
+
if sd_pid.to_i == $$ # n.b. $$ can never be zero
|
774
774
|
# 3 = SD_LISTEN_FDS_START
|
775
|
-
inherited.concat((3...(3 + sd_fds.to_i)).
|
775
|
+
inherited.concat((3...(3 + sd_fds.to_i)).to_a)
|
776
776
|
end
|
777
777
|
# to ease debugging, we will not unset LISTEN_PID and LISTEN_FDS
|
778
778
|
|
779
779
|
inherited.map! do |fd|
|
780
|
-
io =
|
780
|
+
io = Socket.for_fd(fd.to_i)
|
781
781
|
io.autoclose = false
|
782
782
|
io = server_cast(io)
|
783
783
|
set_server_sockopt(io, listener_opts[sock_name(io)])
|
@@ -5,14 +5,12 @@ require 'socket'
|
|
5
5
|
module Unicorn
|
6
6
|
module SocketHelper
|
7
7
|
|
8
|
-
# internal interface
|
8
|
+
# internal interface
|
9
9
|
DEFAULTS = {
|
10
10
|
# The semantics for TCP_DEFER_ACCEPT changed in Linux 2.6.32+
|
11
11
|
# with commit d1b99ba41d6c5aa1ed2fc634323449dd656899e9
|
12
|
-
# This change shouldn't affect
|
13
|
-
# value of 1 remains an optimization)
|
14
|
-
# want to use a higher value on Linux 2.6.32+ to protect against
|
15
|
-
# denial-of-service attacks
|
12
|
+
# This change shouldn't affect unicorn users behind nginx (a
|
13
|
+
# value of 1 remains an optimization).
|
16
14
|
:tcp_defer_accept => 1,
|
17
15
|
|
18
16
|
# FreeBSD, we need to override this to 'dataready' if we
|
data/lib/unicorn/stream_input.rb
CHANGED
@@ -53,7 +53,7 @@ class Unicorn::StreamInput
|
|
53
53
|
rv << @rbuf
|
54
54
|
to_read -= @rbuf.size
|
55
55
|
end
|
56
|
-
@rbuf.
|
56
|
+
@rbuf.clear
|
57
57
|
end
|
58
58
|
rv = nil if rv.empty? && length != 0
|
59
59
|
else
|
@@ -130,8 +130,8 @@ private
|
|
130
130
|
filter_body(@rbuf, @buf)
|
131
131
|
dst << @rbuf
|
132
132
|
end
|
133
|
-
|
134
|
-
|
133
|
+
ensure
|
134
|
+
@rbuf.clear
|
135
135
|
end
|
136
136
|
|
137
137
|
def eof!
|
data/lib/unicorn/util.rb
CHANGED
data/lib/unicorn/worker.rb
CHANGED
@@ -3,8 +3,8 @@ require "raindrops"
|
|
3
3
|
|
4
4
|
# This class and its members can be considered a stable interface
|
5
5
|
# and will not change in a backwards-incompatible fashion between
|
6
|
-
# releases of
|
7
|
-
# not needed for most users of
|
6
|
+
# releases of unicorn. Knowledge of this class is generally not
|
7
|
+
# not needed for most users of unicorn.
|
8
8
|
#
|
9
9
|
# Some users may want to access it in the before_fork/after_fork hooks.
|
10
10
|
# See the Unicorn::Configurator RDoc for examples.
|
data/test/exec/test_exec.rb
CHANGED
@@ -99,23 +99,51 @@ run lambda { |env|
|
|
99
99
|
def test_sd_listen_fds_emulation
|
100
100
|
File.open("config.ru", "wb") { |fp| fp.write(HI) }
|
101
101
|
sock = TCPServer.new(@addr, @port)
|
102
|
+
|
103
|
+
[ %W(-l #@addr:#@port), nil ].each do |l|
|
104
|
+
sock.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, 0)
|
105
|
+
|
106
|
+
pid = xfork do
|
107
|
+
redirect_test_io do
|
108
|
+
# pretend to be systemd
|
109
|
+
ENV['LISTEN_PID'] = "#$$"
|
110
|
+
ENV['LISTEN_FDS'] = '1'
|
111
|
+
|
112
|
+
# 3 = SD_LISTEN_FDS_START
|
113
|
+
args = [ $unicorn_bin ]
|
114
|
+
args.concat(l) if l
|
115
|
+
args << { 3 => sock }
|
116
|
+
exec(*args)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
res = hit(["http://#@addr:#@port/"])
|
120
|
+
assert_equal [ "HI\n" ], res
|
121
|
+
assert_shutdown(pid)
|
122
|
+
assert_equal 1, sock.getsockopt(:SOL_SOCKET, :SO_KEEPALIVE).int,
|
123
|
+
'unicorn should always set SO_KEEPALIVE on inherited sockets'
|
124
|
+
end
|
125
|
+
ensure
|
126
|
+
sock.close if sock
|
127
|
+
# disabled test on old Rubies: https://bugs.ruby-lang.org/issues/11336
|
128
|
+
# [ruby-core:69895] [Bug #11336] fixed by r51576
|
129
|
+
end if RUBY_VERSION.to_f >= 2.3
|
130
|
+
|
131
|
+
def test_inherit_listener_unspecified
|
132
|
+
File.open("config.ru", "wb") { |fp| fp.write(HI) }
|
133
|
+
sock = TCPServer.new(@addr, @port)
|
102
134
|
sock.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, 0)
|
103
135
|
|
104
136
|
pid = xfork do
|
105
137
|
redirect_test_io do
|
106
|
-
|
107
|
-
|
108
|
-
ENV['LISTEN_FDS'] = '1'
|
109
|
-
|
110
|
-
# 3 = SD_LISTEN_FDS_START
|
111
|
-
exec($unicorn_bin, "-l", "#@addr:#@port", 3 => sock)
|
138
|
+
ENV['UNICORN_FD'] = sock.fileno.to_s
|
139
|
+
exec($unicorn_bin, sock.fileno => sock.fileno)
|
112
140
|
end
|
113
141
|
end
|
114
|
-
res = hit(["http
|
115
|
-
assert_equal [ "HI\n"], res
|
142
|
+
res = hit(["http://#@addr:#@port/"])
|
143
|
+
assert_equal [ "HI\n" ], res
|
116
144
|
assert_shutdown(pid)
|
117
145
|
assert_equal 1, sock.getsockopt(:SOL_SOCKET, :SO_KEEPALIVE).int,
|
118
|
-
|
146
|
+
'unicorn should always set SO_KEEPALIVE on inherited sockets'
|
119
147
|
ensure
|
120
148
|
sock.close if sock
|
121
149
|
end
|
data/unicorn.gemspec
CHANGED
@@ -26,6 +26,11 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.homepage = Olddoc.config['rdoc_url']
|
27
27
|
s.test_files = test_files
|
28
28
|
|
29
|
+
# technically we need ">= 1.9.3", too, but avoid the array here since
|
30
|
+
# old rubygems versions (1.8.23.2 at least) do not support multiple
|
31
|
+
# version requirements here.
|
32
|
+
s.required_ruby_version = '< 3.0'
|
33
|
+
|
29
34
|
# for people that are absolutely stuck on Rails 2.3.2 and can't
|
30
35
|
# up/downgrade to any other version, the Rack dependency may be
|
31
36
|
# commented out. Nevertheless, upgrading to Rails 2.3.4 or later is
|
@@ -37,5 +42,9 @@ Gem::Specification.new do |s|
|
|
37
42
|
s.add_development_dependency('test-unit', '~> 3.0')
|
38
43
|
s.add_development_dependency('olddoc', '~> 1.0')
|
39
44
|
|
40
|
-
|
45
|
+
# Note: To avoid ambiguity, we intentionally avoid the SPDX-compatible
|
46
|
+
# 'Ruby' here since Ruby 1.9.3 switched to BSD-2-Clause, but we
|
47
|
+
# inherited our license from Mongrel when Ruby was at 1.8.
|
48
|
+
# We cannot automatically switch licenses when Ruby changes.
|
49
|
+
s.licenses = ['GPL-2.0+', 'Ruby-1.8']
|
41
50
|
end
|
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.0
|
4
|
+
version: 5.0.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: 2015-
|
11
|
+
date: 2015-11-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -81,11 +81,11 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
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
|
86
86
|
advantage of features in Unix/Unix-like kernels. Slow clients should
|
87
87
|
only be served by placing a reverse proxy capable of fully buffering
|
88
|
-
both the the request and response in between
|
88
|
+
both the the request and response in between unicorn and slow clients.
|
89
89
|
email: unicorn-public@bogomips.org
|
90
90
|
executables:
|
91
91
|
- unicorn
|
@@ -279,8 +279,8 @@ files:
|
|
279
279
|
- unicorn_rails_1
|
280
280
|
homepage: http://unicorn.bogomips.org/
|
281
281
|
licenses:
|
282
|
-
-
|
283
|
-
- Ruby
|
282
|
+
- GPL-2.0+
|
283
|
+
- Ruby-1.8
|
284
284
|
metadata: {}
|
285
285
|
post_install_message:
|
286
286
|
rdoc_options: []
|
@@ -288,17 +288,17 @@ require_paths:
|
|
288
288
|
- lib
|
289
289
|
required_ruby_version: !ruby/object:Gem::Requirement
|
290
290
|
requirements:
|
291
|
-
- - "
|
291
|
+
- - "<"
|
292
292
|
- !ruby/object:Gem::Version
|
293
|
-
version: '0'
|
293
|
+
version: '3.0'
|
294
294
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
295
295
|
requirements:
|
296
|
-
- - "
|
296
|
+
- - ">="
|
297
297
|
- !ruby/object:Gem::Version
|
298
|
-
version:
|
298
|
+
version: '0'
|
299
299
|
requirements: []
|
300
300
|
rubyforge_project:
|
301
|
-
rubygems_version: 2.
|
301
|
+
rubygems_version: 2.5.0
|
302
302
|
signing_key:
|
303
303
|
specification_version: 4
|
304
304
|
summary: Rack HTTP server for fast clients and Unix
|