unicorn 5.4.1 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.manifest +10 -5
- data/.olddoc.yml +15 -7
- data/Application_Timeouts +4 -4
- data/CONTRIBUTORS +6 -2
- data/Documentation/.gitignore +1 -3
- data/Documentation/unicorn.1 +222 -0
- data/Documentation/unicorn_rails.1 +207 -0
- data/FAQ +1 -1
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +112 -57
- data/HACKING +2 -9
- data/ISSUES +29 -33
- data/KNOWN_ISSUES +2 -2
- data/LATEST +16 -21
- data/LICENSE +2 -2
- data/Links +13 -11
- data/NEWS +197 -0
- data/README +27 -14
- data/SIGNALS +1 -1
- data/Sandbox +5 -5
- data/archive/slrnpull.conf +1 -1
- data/bin/unicorn +3 -1
- data/bin/unicorn_rails +2 -2
- data/examples/big_app_gc.rb +1 -1
- data/examples/logrotate.conf +3 -3
- data/examples/nginx.conf +4 -3
- data/examples/unicorn.conf.minimal.rb +2 -2
- data/examples/unicorn.conf.rb +2 -2
- data/examples/unicorn@.service +7 -0
- data/ext/unicorn_http/c_util.h +5 -13
- data/ext/unicorn_http/common_field_optimization.h +23 -6
- data/ext/unicorn_http/epollexclusive.h +124 -0
- data/ext/unicorn_http/ext_help.h +0 -24
- data/ext/unicorn_http/extconf.rb +32 -6
- data/ext/unicorn_http/global_variables.h +3 -3
- data/ext/unicorn_http/httpdate.c +3 -2
- data/ext/unicorn_http/unicorn_http.c +262 -237
- data/ext/unicorn_http/unicorn_http.rl +52 -27
- data/lib/unicorn/configurator.rb +25 -4
- data/lib/unicorn/http_request.rb +12 -3
- data/lib/unicorn/http_server.rb +62 -36
- data/lib/unicorn/launcher.rb +1 -1
- data/lib/unicorn/oob_gc.rb +5 -5
- data/lib/unicorn/select_waiter.rb +6 -0
- data/lib/unicorn/socket_helper.rb +1 -0
- data/lib/unicorn/tmpio.rb +8 -2
- data/lib/unicorn/util.rb +1 -1
- data/lib/unicorn/version.rb +1 -1
- data/lib/unicorn/worker.rb +16 -2
- data/lib/unicorn.rb +21 -9
- data/man/man1/unicorn.1 +89 -88
- data/man/man1/unicorn_rails.1 +78 -83
- data/t/GNUmakefile +3 -72
- data/t/README +4 -4
- data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
- data/t/t0301.ru +13 -0
- data/t/test-lib.sh +2 -1
- data/test/benchmark/README +14 -4
- data/test/benchmark/ddstream.ru +50 -0
- data/test/benchmark/readinput.ru +40 -0
- data/test/benchmark/uconnect.perl +66 -0
- data/test/exec/test_exec.rb +14 -12
- data/test/test_helper.rb +38 -30
- data/test/unit/test_ccc.rb +4 -3
- data/test/unit/test_http_parser.rb +16 -0
- data/test/unit/test_http_parser_ng.rb +81 -0
- data/test/unit/test_server.rb +81 -7
- data/test/unit/test_signals.rb +6 -6
- data/test/unit/test_socket_helper.rb +1 -1
- data/test/unit/test_upload.rb +9 -14
- data/test/unit/test_util.rb +29 -3
- data/test/unit/test_waiter.rb +34 -0
- data/unicorn.gemspec +8 -7
- metadata +19 -13
- data/Documentation/GNUmakefile +0 -30
- data/Documentation/unicorn.1.txt +0 -187
- data/Documentation/unicorn_rails.1.txt +0 -175
- data/t/hijack.ru +0 -55
- data/t/t0200-rack-hijack.sh +0 -51
data/NEWS
CHANGED
@@ -1,3 +1,200 @@
|
|
1
|
+
=== unicorn 6.0.0 - no more recycling Rack env / 2021-03-17 06:38 UTC
|
2
|
+
|
3
|
+
This release allocates a new Rack `env' hash for every request.
|
4
|
+
This is done for safety with internally-(thread|event)-using Rack
|
5
|
+
apps which expect to use `env' after the normal Rack response is
|
6
|
+
complete, but without relying on rack.hijack[1]. Thanks to
|
7
|
+
Dirkjan Bussink <d.bussink@gmail.com> for the patch:
|
8
|
+
|
9
|
+
https://yhbt.net/unicorn-public/66A68DD8-83EF-4C7A-80E8-3F1F7AB31670@github.com/
|
10
|
+
|
11
|
+
The major version is bumped since:
|
12
|
+
|
13
|
+
1) there are performance regressions for some simple Rack apps
|
14
|
+
|
15
|
+
2) unsupported 3rd-party monkey patches which previously
|
16
|
+
relied on this behavior may be broken (our version of
|
17
|
+
OobGC was).
|
18
|
+
|
19
|
+
The test suite is also more reliable on multi-core systems
|
20
|
+
and Ruby 3.x.
|
21
|
+
|
22
|
+
[1] thread from 2017 around rack.hijack safety:
|
23
|
+
https://yhbt.net/unicorn-public/CAAtdryPG3nLuyo0jxfYW1YHu1Q+ZpkLkd4KdWC8vA46B5haZxw@mail.gmail.com/
|
24
|
+
|
25
|
+
=== unicorn 5.8.0 - rack.after_reply support / 2020-12-24 20:39 UTC
|
26
|
+
|
27
|
+
This release supports env['rack.after_reply'] which allows
|
28
|
+
rack middleware to pass lambdas to be executed after the client
|
29
|
+
connection is closed, matching functionality in Puma.
|
30
|
+
|
31
|
+
Thanks to Blake Williams for this patch:
|
32
|
+
https://yhbt.net/unicorn-public/9873E53C-04D3-4759-9678-CA17DBAEF7B7@blakewilliams.me/
|
33
|
+
|
34
|
+
The top-level of our website is now simpler and no longer
|
35
|
+
redundant with the contents of https://yhbt.net/unicorn/README.html
|
36
|
+
(which contains the old content)
|
37
|
+
|
38
|
+
=== unicorn 5.7.0 / 2020-09-08 08:41 UTC
|
39
|
+
|
40
|
+
Relaxed Ruby version requirements for Ruby 3.0.0dev.
|
41
|
+
Thanks to Jean Boussier for testing
|
42
|
+
|
43
|
+
=== unicorn 5.6.0 - early_hints support / 2020-07-26 01:52 UTC
|
44
|
+
|
45
|
+
This release adds support for the early_hints configurator
|
46
|
+
directive for the 'rack.early_hints' API used by Rails 5.2+.
|
47
|
+
|
48
|
+
Thanks to Jean Boussier for the patch.
|
49
|
+
|
50
|
+
Link: https://yhbt.net/unicorn-public/242F0859-0F83-4F14-A0FF-5BE392BB01E6@shopify.com/
|
51
|
+
|
52
|
+
=== unicorn 5.5.5 / 2020-04-27 02:48 UTC
|
53
|
+
|
54
|
+
This release fixes a bug for users of multiple listeners setups
|
55
|
+
where a busy listen socket could starve other listeners.
|
56
|
+
|
57
|
+
Thanks to Stan Hu for reporting and testing.
|
58
|
+
|
59
|
+
No need to upgrade if you're using a single listen socket.
|
60
|
+
|
61
|
+
Link: https://yhbt.net/unicorn-public/CAMBWrQ=Yh42MPtzJCEO7XryVknDNetRMuA87irWfqVuLdJmiBQ@mail.gmail.com/
|
62
|
+
|
63
|
+
=== unicorn 5.5.4 / 2020-03-24 22:10 UTC
|
64
|
+
|
65
|
+
One change to improve RFC 7230 conformance in the HTTP parser:
|
66
|
+
|
67
|
+
https://yhbt.net/unicorn-public/20200319022823.32472-1-bofh@yhbt.net/
|
68
|
+
|
69
|
+
=== unicorn 5.5.3 / 2020-01-31 20:39 UTC
|
70
|
+
|
71
|
+
Documentation updates to switch bogomips.org to yhbt.net since
|
72
|
+
the .org TLD won't be affordable in the near future.
|
73
|
+
|
74
|
+
There's also a few minor test cleanups.
|
75
|
+
|
76
|
+
=== unicorn 5.5.2 / 2019-12-20 02:08 UTC
|
77
|
+
|
78
|
+
Thanks to Terry Scheingeld, we now workaround a Ruby bug
|
79
|
+
and can now run with taint checks enabled:
|
80
|
+
<https://bugs.ruby-lang.org/issues/14485>
|
81
|
+
<https://bogomips.org/unicorn-public/CABg1sXrvGv9G6CDQxePDUqTe6N-5UpLXm7eG3YQO=dda-Cgg7A@mail.gmail.com/>
|
82
|
+
|
83
|
+
There's also a few documentation updates and building packages
|
84
|
+
from source is easier since pandoc is no longer a dependency
|
85
|
+
(and I can no longer afford the bandwidth or space to install
|
86
|
+
it).
|
87
|
+
|
88
|
+
Eric Wong (7):
|
89
|
+
test/benchmark/ddstream: demo for slowly reading clients
|
90
|
+
test/benchmark/readinput: demo for slowly uploading clients
|
91
|
+
test/benchmark/uconnect: test for accept loop speed
|
92
|
+
examples/unicorn@.service: note the NonBlocking flag
|
93
|
+
Merge remote-tracking branch 'origin/ts/tmpio'
|
94
|
+
test_util: get rid of some unused variables in tests
|
95
|
+
doc: replace pandoc-"Markdown" with real manpages
|
96
|
+
|
97
|
+
Terry Scheingeld (1):
|
98
|
+
tmpio: workaround File#path being tainted on unlink
|
99
|
+
|
100
|
+
=== unicorn 5.5.1 / 2019-05-06 06:40 UTC
|
101
|
+
|
102
|
+
This release fixes and works around issues from v5.5.0 (2019-03-04)
|
103
|
+
|
104
|
+
Stephen Demjanenko worked around a pipe resource accounting bug
|
105
|
+
present in old Linux kernels. Linux 3.x users from 3.16.57 and
|
106
|
+
on are unaffected. Linux 4.x users from 4.9 and on are
|
107
|
+
unaffected.
|
108
|
+
|
109
|
+
https://bogomips.org/unicorn-public/1556922018-24096-1-git-send-email-sdemjanenko@gmail.com/
|
110
|
+
|
111
|
+
Stan Pitucha reported a bug with the old `unicorn_rails' wrapper
|
112
|
+
(intended for Rails 2.x users) which was promptly fixed by
|
113
|
+
Jeremy Evans:
|
114
|
+
|
115
|
+
https://bogomips.org/unicorn-public/CAJ2_uEPifcv_ux4sX=t0C4zHTHGhqVfcLcSB2kTU3Rb_6pQ3nw@mail.gmail.com/
|
116
|
+
|
117
|
+
There's also some doc updates to warn users off `unicorn_rails';
|
118
|
+
the homepage is now energy-efficient for OLEDs and CRTs;
|
119
|
+
and I'm no longer advertising mailing list subscriptions
|
120
|
+
(because I hate centralization and mail archives are the priority)
|
121
|
+
|
122
|
+
Eric Wong (3):
|
123
|
+
doc: unicorn_rails: clarify that it is intended for rails <= 2.x
|
124
|
+
doc: stop advertising mailing list subscription
|
125
|
+
doc: switch homepage to dark216
|
126
|
+
|
127
|
+
Jeremy Evans (1):
|
128
|
+
unicorn_rails: fix regression with Rails >= 3.x in app build
|
129
|
+
|
130
|
+
Stephen Demjanenko (1):
|
131
|
+
Rescue failed pipe resizes due to permissions
|
132
|
+
|
133
|
+
=== unicorn 5.5.0 / 2019-03-04 00:41 UTC
|
134
|
+
|
135
|
+
Mostly identical to 5.5.0.pre1, which I didn't hear any feedback
|
136
|
+
from:
|
137
|
+
|
138
|
+
https://bogomips.org/unicorn-public/20181220222842.GA27382@dcvr/
|
139
|
+
|
140
|
+
> Jeremy Evans contributed the "default_middleware" configuration option:
|
141
|
+
>
|
142
|
+
> https://bogomips.org/unicorn-public/20180913192055.GD48926@jeremyevans.local/
|
143
|
+
>
|
144
|
+
> Jeremy also contributed the ability to use separate groups for the process
|
145
|
+
> and log files:
|
146
|
+
>
|
147
|
+
> https://bogomips.org/unicorn-public/20180913192449.GE48926@jeremyevans.local/
|
148
|
+
>
|
149
|
+
> There's also a couple of uninteresting minor optimizations and
|
150
|
+
> documentation additions.
|
151
|
+
|
152
|
+
Otherwise, there's one extra change to use
|
153
|
+
rb_gc_register_mark_object which is finally a documented part of
|
154
|
+
the Ruby C-API, but has existed since the 1.9 days.
|
155
|
+
|
156
|
+
=== unicorn 5.5.0.pre1 / 2018-12-20 20:11 UTC
|
157
|
+
|
158
|
+
Jeremy Evans contributed the "default_middleware" configuration option:
|
159
|
+
|
160
|
+
https://bogomips.org/unicorn-public/20180913192055.GD48926@jeremyevans.local/
|
161
|
+
|
162
|
+
Jeremy also contributed the ability to use separate groups for the process
|
163
|
+
and log files:
|
164
|
+
|
165
|
+
https://bogomips.org/unicorn-public/20180913192449.GE48926@jeremyevans.local/
|
166
|
+
|
167
|
+
There's also a couple of uninteresting minor optimizations and
|
168
|
+
documentation additions.
|
169
|
+
|
170
|
+
Eric Wong (10):
|
171
|
+
remove random seed reset atfork
|
172
|
+
use IO#wait instead of kgio_wait_readable
|
173
|
+
Merge branch '5.4-stable'
|
174
|
+
shrink pipes under Linux
|
175
|
+
socket_helper: add hint for FreeBSD users for accf_http(9)
|
176
|
+
tests: ensure -N/--no-default-middleware not supported in config.ru
|
177
|
+
doc: update more URLs to use HTTPS and avoid redirects
|
178
|
+
deduplicate strings VM-wide in Ruby 2.5+
|
179
|
+
doc/ISSUES: add links to git clone-able mail archives of our dependencies
|
180
|
+
README: minor updates and additional disclaimer
|
181
|
+
|
182
|
+
Jeremy Evans (2):
|
183
|
+
Make Worker#user support different process primary group and log file group
|
184
|
+
Support default_middleware configuration option
|
185
|
+
|
186
|
+
=== unicorn 5.4.1 / 2018-07-23 17:13 UTC
|
187
|
+
|
188
|
+
This release quiets some warnings for Ruby 2.6 preview releases
|
189
|
+
and enables tests to pass under Ruby 1.9.3. Otherwise, nothing
|
190
|
+
interesting for Ruby 2.0..2.5 users. *YAWN*
|
191
|
+
|
192
|
+
Eric Wong (1):
|
193
|
+
quiet some mismatched indentation warnings
|
194
|
+
|
195
|
+
Fumiaki MATSUSHIMA (1):
|
196
|
+
Use IO#wait instead to fix test for Ruby 1.9
|
197
|
+
|
1
198
|
=== unicorn 5.4.0 / 2017-12-23 23:33 UTC
|
2
199
|
|
3
200
|
Rack hijack support improves as the app code can capture and use
|
data/README
CHANGED
@@ -10,10 +10,9 @@ both the the request and response in between unicorn and slow clients.
|
|
10
10
|
|
11
11
|
* Designed for Rack, Unix, fast clients, and ease-of-debugging. We
|
12
12
|
cut out everything that is better supported by the operating system,
|
13
|
-
{nginx}[
|
13
|
+
{nginx}[https://nginx.org/] or {Rack}[https://rack.github.io/].
|
14
14
|
|
15
|
-
* Compatible with Ruby
|
16
|
-
unicorn 4.x remains supported for Ruby 1.8 users.
|
15
|
+
* Compatible with Ruby 2.0.0 and later.
|
17
16
|
|
18
17
|
* Process management: unicorn will reap and restart workers that
|
19
18
|
die from broken apps. There is no need to manage multiple processes
|
@@ -37,12 +36,15 @@ both the the request and response in between unicorn and slow clients.
|
|
37
36
|
You can upgrade unicorn, your entire application, libraries
|
38
37
|
and even your Ruby interpreter without dropping clients.
|
39
38
|
|
39
|
+
* transparent upgrades using systemd socket activation is
|
40
|
+
supported since unicorn 5.0
|
41
|
+
|
40
42
|
* before_fork and after_fork hooks in case your application
|
41
43
|
has special needs when dealing with forked processes. These
|
42
44
|
should not be needed when the "preload_app" directive is
|
43
45
|
false (the default).
|
44
46
|
|
45
|
-
* Can be used with copy-on-write-friendly
|
47
|
+
* Can be used with copy-on-write-friendly GC in Ruby 2.0+
|
46
48
|
to save memory (by setting "preload_app" to true).
|
47
49
|
|
48
50
|
* Able to listen on multiple interfaces including UNIX sockets,
|
@@ -55,7 +57,7 @@ both the the request and response in between unicorn and slow clients.
|
|
55
57
|
|
56
58
|
== License
|
57
59
|
|
58
|
-
unicorn is copyright 2009-
|
60
|
+
unicorn is copyright 2009-2018 by all contributors (see logs in git).
|
59
61
|
It is based on Mongrel 1.1.5.
|
60
62
|
Mongrel is copyright 2007 Zed A. Shaw and contributors.
|
61
63
|
|
@@ -77,13 +79,13 @@ You may install it via RubyGems on RubyGems.org:
|
|
77
79
|
You can get the latest source via git from the following locations
|
78
80
|
(these versions may not be stable):
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
+
https://yhbt.net/unicorn.git
|
83
|
+
https://repo.or.cz/unicorn.git (mirror)
|
82
84
|
|
83
85
|
You may browse the code from the web:
|
84
86
|
|
85
|
-
* https://
|
86
|
-
*
|
87
|
+
* https://yhbt.net/unicorn.git
|
88
|
+
* https://repo.or.cz/w/unicorn.git (gitweb)
|
87
89
|
|
88
90
|
See the HACKING guide on how to contribute and build prerelease gems
|
89
91
|
from git.
|
@@ -122,17 +124,28 @@ unicorn is designed to only serve fast clients either on the local host
|
|
122
124
|
or a fast LAN. See the PHILOSOPHY and DESIGN documents for more details
|
123
125
|
regarding this.
|
124
126
|
|
127
|
+
Due to its ability to tolerate crashes and isolate clients, unicorn
|
128
|
+
is unfortunately known to prolong the existence of bugs in applications
|
129
|
+
and libraries which run on top of it.
|
130
|
+
|
125
131
|
== Contact
|
126
132
|
|
127
133
|
All feedback (bug reports, user/development dicussion, patches, pull
|
128
134
|
requests) go to the mailing list/newsgroup. See the ISSUES document for
|
129
|
-
information on the {mailing list}[mailto:unicorn-public@
|
135
|
+
information on the {mailing list}[mailto:unicorn-public@yhbt.net].
|
136
|
+
|
137
|
+
The mailing list is archived at https://yhbt.net/unicorn-public/
|
130
138
|
|
131
|
-
The mailing list is archived at https://bogomips.org/unicorn-public/
|
132
139
|
Read-only NNTP access is available at:
|
133
|
-
|
134
|
-
nntp://news.gmane.
|
140
|
+
nntps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn and
|
141
|
+
nntp://news.gmane.io/gmane.comp.lang.ruby.unicorn.general
|
142
|
+
|
143
|
+
Read-only IMAP access is also avaialble at:
|
144
|
+
imaps://yhbt.net/inbox.comp.lang.ruby.unicorn.0 and
|
145
|
+
imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.unicorn.0
|
146
|
+
The AUTH=ANONYMOUS mechanism is supported, as is any username+password
|
147
|
+
combination.
|
135
148
|
|
136
149
|
For the latest on unicorn releases, you may also finger us at
|
137
|
-
unicorn@
|
150
|
+
unicorn@yhbt.net or check our NEWS page (and subscribe to our Atom
|
138
151
|
feed).
|
data/SIGNALS
CHANGED
@@ -8,7 +8,7 @@ should be possible to easily share process management scripts between
|
|
8
8
|
Unicorn and nginx.
|
9
9
|
|
10
10
|
One example init script is distributed with unicorn:
|
11
|
-
https://
|
11
|
+
https://yhbt.net/unicorn/examples/init.sh
|
12
12
|
|
13
13
|
=== Master Process
|
14
14
|
|
data/Sandbox
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Since unicorn includes executables and is usually used to start a Ruby
|
4
4
|
process, there are certain caveats to using it with tools that sandbox
|
5
5
|
RubyGems installations such as
|
6
|
-
{Bundler}[
|
6
|
+
{Bundler}[https://bundler.io/] or
|
7
7
|
{Isolate}[https://github.com/jbarnette/isolate].
|
8
8
|
|
9
9
|
== General deployment
|
@@ -34,7 +34,7 @@ is the primary issue with sandboxing tools such as Bundler and Isolate.
|
|
34
34
|
If you're bundling unicorn, use "bundle exec unicorn" (or "bundle exec
|
35
35
|
unicorn_rails") to start unicorn with the correct environment variables
|
36
36
|
|
37
|
-
ref: https://
|
37
|
+
ref: https://yhbt.net/unicorn-public/9ECF07C4-5216-47BE-961D-AFC0F0C82060@internetfamo.us/
|
38
38
|
|
39
39
|
Otherwise (if you choose to not sandbox your unicorn installation), we
|
40
40
|
expect the tips for Isolate (below) apply, too.
|
@@ -44,7 +44,7 @@ expect the tips for Isolate (below) apply, too.
|
|
44
44
|
This is no longer be an issue as of bundler 0.9.17
|
45
45
|
|
46
46
|
ref:
|
47
|
-
https://
|
47
|
+
https://yhbt.net/unicorn-public/8FC34B23-5994-41CC-B5AF-7198EF06909E@tramchase.com/
|
48
48
|
|
49
49
|
=== BUNDLE_GEMFILE for Capistrano users
|
50
50
|
|
@@ -66,7 +66,7 @@ before_exec hook as illustrated by https://gist.github.com/534668
|
|
66
66
|
Ruby 2.0.0 enforces FD_CLOEXEC on file descriptors by default. unicorn
|
67
67
|
has been prepared for this behavior since unicorn 4.1.0, and bundler
|
68
68
|
needs the "--keep-file-descriptors" option for "bundle exec":
|
69
|
-
|
69
|
+
https://bundler.io/man/bundle-exec.1.html
|
70
70
|
|
71
71
|
== Isolate
|
72
72
|
|
@@ -87,7 +87,7 @@ For now workarounds include doing one of the following:
|
|
87
87
|
|
88
88
|
3. Explicitly setting RUBYLIB or $LOAD_PATH to include any gem path
|
89
89
|
where the unicorn gem is installed
|
90
|
-
(e.g. /usr/lib/ruby/gems/
|
90
|
+
(e.g. /usr/lib/ruby/gems/3.0.0/gems/unicorn-VERSION/lib)
|
91
91
|
|
92
92
|
=== RUBYOPT pollution from SIGUSR2 upgrades
|
93
93
|
|
data/archive/slrnpull.conf
CHANGED
data/bin/unicorn
CHANGED
@@ -6,6 +6,7 @@ require 'optparse'
|
|
6
6
|
ENV["RACK_ENV"] ||= "development"
|
7
7
|
rackup_opts = Unicorn::Configurator::RACKUP
|
8
8
|
options = rackup_opts[:options]
|
9
|
+
set_no_default_middleware = true
|
9
10
|
|
10
11
|
op = OptionParser.new("", 24, ' ') do |opts|
|
11
12
|
cmd = File.basename($0)
|
@@ -60,7 +61,7 @@ op = OptionParser.new("", 24, ' ') do |opts|
|
|
60
61
|
|
61
62
|
opts.on("-N", "--no-default-middleware",
|
62
63
|
"do not load middleware implied by RACK_ENV") do |e|
|
63
|
-
rackup_opts[:no_default_middleware] = true
|
64
|
+
rackup_opts[:no_default_middleware] = true if set_no_default_middleware
|
64
65
|
end
|
65
66
|
|
66
67
|
opts.on("-D", "--daemonize", "run daemonized in the background") do |d|
|
@@ -110,6 +111,7 @@ op = OptionParser.new("", 24, ' ') do |opts|
|
|
110
111
|
opts.parse! ARGV
|
111
112
|
end
|
112
113
|
|
114
|
+
set_no_default_middleware = false
|
113
115
|
app = Unicorn.builder(ARGV[0] || 'config.ru', op)
|
114
116
|
op = nil
|
115
117
|
|
data/bin/unicorn_rails
CHANGED
@@ -132,11 +132,11 @@ def rails_builder(ru, op, daemonize)
|
|
132
132
|
|
133
133
|
# this lambda won't run until after forking if preload_app is false
|
134
134
|
# this runs after config file reloading
|
135
|
-
lambda do
|
135
|
+
lambda do |x, server|
|
136
136
|
# Rails 3 includes a config.ru, use it if we find it after
|
137
137
|
# working_directory is bound.
|
138
138
|
::File.exist?('config.ru') and
|
139
|
-
return Unicorn.builder('config.ru', op).call
|
139
|
+
return Unicorn.builder('config.ru', op).call(x, server)
|
140
140
|
|
141
141
|
# Load Rails and (possibly) the private version of Rack it bundles.
|
142
142
|
begin
|
data/examples/big_app_gc.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
# see {Unicorn::OobGC}[https://
|
1
|
+
# see {Unicorn::OobGC}[https://yhbt.net/unicorn/Unicorn/OobGC.html]
|
2
2
|
# Unicorn::OobGC was broken in Unicorn v3.3.1 - v3.6.1 and fixed in v3.6.2
|
data/examples/logrotate.conf
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
# /etc/logrotate.d/unicorn_app on my Debian systems
|
3
3
|
#
|
4
4
|
# See the logrotate(8) manpage for more information:
|
5
|
-
#
|
5
|
+
# https://linux.die.net/man/8/logrotate
|
6
6
|
#
|
7
7
|
# public logrotate-related discussion in our archives:
|
8
|
-
# https://
|
8
|
+
# https://yhbt.net/unicorn-public/?q=logrotate
|
9
9
|
|
10
10
|
# Modify the following glob to match the logfiles your app writes to:
|
11
11
|
/var/log/unicorn_app/*.log {
|
@@ -33,7 +33,7 @@
|
|
33
33
|
systemctl kill -s SIGUSR1 unicorn@2.service
|
34
34
|
|
35
35
|
# Examples for other process management systems appreciated
|
36
|
-
# Mail us at unicorn-public@
|
36
|
+
# Mail us at unicorn-public@yhbt.net
|
37
37
|
# (see above for archives)
|
38
38
|
|
39
39
|
# If you use a pid file and assuming your pid file
|
data/examples/nginx.conf
CHANGED
@@ -56,7 +56,8 @@ http {
|
|
56
56
|
# to configure it all in one place here for static files and also
|
57
57
|
# to disable gzip for clients who don't get gzip/deflate right.
|
58
58
|
# There are other gzip settings that may be needed used to deal with
|
59
|
-
# bad clients out there, see
|
59
|
+
# bad clients out there, see
|
60
|
+
# https://nginx.org/en/docs/http/ngx_http_gzip_module.html
|
60
61
|
gzip on;
|
61
62
|
gzip_http_version 1.0;
|
62
63
|
gzip_proxied any;
|
@@ -112,12 +113,12 @@ http {
|
|
112
113
|
# try_files directive appeared in in nginx 0.7.27 and has stabilized
|
113
114
|
# over time. Older versions of nginx (e.g. 0.6.x) requires
|
114
115
|
# "if (!-f $request_filename)" which was less efficient:
|
115
|
-
# https://
|
116
|
+
# https://yhbt.net/unicorn.git/tree/examples/nginx.conf?id=v3.3.1#n127
|
116
117
|
try_files $uri/index.html $uri.html $uri @app;
|
117
118
|
|
118
119
|
location @app {
|
119
120
|
# an HTTP header important enough to have its own Wikipedia entry:
|
120
|
-
#
|
121
|
+
# https://en.wikipedia.org/wiki/X-Forwarded-For
|
121
122
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
122
123
|
|
123
124
|
# enable this if you forward HTTPS traffic to unicorn,
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Minimal sample configuration file for Unicorn (not Rack) when used
|
2
2
|
# with daemonization (unicorn -D) started in your working directory.
|
3
3
|
#
|
4
|
-
# See https://
|
4
|
+
# See https://yhbt.net/unicorn/Unicorn/Configurator.html for complete
|
5
5
|
# documentation.
|
6
|
-
# See also https://
|
6
|
+
# See also https://yhbt.net/unicorn/examples/unicorn.conf.rb for
|
7
7
|
# a more verbose configuration using more features.
|
8
8
|
|
9
9
|
listen 2007 # by default Unicorn listens on port 8080
|
data/examples/unicorn.conf.rb
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
#
|
3
3
|
# This configuration file documents many features of Unicorn
|
4
4
|
# that may not be needed for some applications. See
|
5
|
-
# https://
|
5
|
+
# https://yhbt.net/unicorn/examples/unicorn.conf.minimal.rb
|
6
6
|
# for a much simpler configuration file.
|
7
7
|
#
|
8
|
-
# See https://
|
8
|
+
# See https://yhbt.net/unicorn/Unicorn/Configurator.html for complete
|
9
9
|
# documentation.
|
10
10
|
|
11
11
|
# Use at least one worker per core if you're on a dedicated server,
|
data/examples/unicorn@.service
CHANGED
@@ -14,7 +14,14 @@ After = unicorn.socket
|
|
14
14
|
# bundler users must use the "--keep-file-descriptors" switch, here:
|
15
15
|
# ExecStart = bundle exec --keep-file-descriptors unicorn -c ...
|
16
16
|
ExecStart = /usr/bin/unicorn -c /path/to/unicorn.conf.rb /path/to/config.ru
|
17
|
+
|
18
|
+
# NonBlocking MUST be true if using socket activation with unicorn.
|
19
|
+
# Otherwise, there's a small window in-between when the non-blocking
|
20
|
+
# flag is set by us and our accept4 call where systemd can momentarily
|
21
|
+
# make the socket blocking, causing us to block on accept4:
|
22
|
+
NonBlocking = true
|
17
23
|
Sockets = unicorn.socket
|
24
|
+
|
18
25
|
KillSignal = SIGQUIT
|
19
26
|
User = nobody
|
20
27
|
Group = nogroup
|
data/ext/unicorn_http/c_util.h
CHANGED
@@ -8,23 +8,15 @@
|
|
8
8
|
|
9
9
|
#include <unistd.h>
|
10
10
|
#include <assert.h>
|
11
|
+
#include <limits.h>
|
11
12
|
|
12
13
|
#define MIN(a,b) (a < b ? a : b)
|
13
14
|
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
|
14
15
|
|
15
|
-
#
|
16
|
-
# define
|
17
|
-
#
|
18
|
-
#
|
19
|
-
|
20
|
-
#if SIZEOF_OFF_T == 4
|
21
|
-
# define UH_OFF_T_MAX 0x7fffffff
|
22
|
-
#elif SIZEOF_OFF_T == 8
|
23
|
-
# if SIZEOF_LONG == 4
|
24
|
-
# define UH_OFF_T_MAX 0x7fffffffffffffffLL
|
25
|
-
# else
|
26
|
-
# define UH_OFF_T_MAX 0x7fffffffffffffff
|
27
|
-
# endif
|
16
|
+
#if SIZEOF_OFF_T == SIZEOF_INT
|
17
|
+
# define UH_OFF_T_MAX INT_MAX
|
18
|
+
#elif SIZEOF_OFF_T == SIZEOF_LONG_LONG
|
19
|
+
# define UH_OFF_T_MAX LLONG_MAX
|
28
20
|
#else
|
29
21
|
# error off_t size unknown for this platform!
|
30
22
|
#endif /* SIZEOF_OFF_T check */
|
@@ -58,26 +58,43 @@ static struct common_field common_http_fields[] = {
|
|
58
58
|
|
59
59
|
#define HTTP_PREFIX "HTTP_"
|
60
60
|
#define HTTP_PREFIX_LEN (sizeof(HTTP_PREFIX) - 1)
|
61
|
+
static ID id_uminus;
|
62
|
+
|
63
|
+
/* this dedupes under Ruby 2.5+ (December 2017) */
|
64
|
+
static VALUE str_dd_freeze(VALUE str)
|
65
|
+
{
|
66
|
+
if (STR_UMINUS_DEDUPE)
|
67
|
+
return rb_funcall(str, id_uminus, 0);
|
68
|
+
|
69
|
+
/* freeze,since it speeds up older MRI slightly */
|
70
|
+
OBJ_FREEZE(str);
|
71
|
+
return str;
|
72
|
+
}
|
73
|
+
|
74
|
+
static VALUE str_new_dd_freeze(const char *ptr, long len)
|
75
|
+
{
|
76
|
+
return str_dd_freeze(rb_str_new(ptr, len));
|
77
|
+
}
|
61
78
|
|
62
79
|
/* this function is not performance-critical, called only at load time */
|
63
|
-
static void init_common_fields(
|
80
|
+
static void init_common_fields(void)
|
64
81
|
{
|
65
82
|
int i;
|
66
83
|
struct common_field *cf = common_http_fields;
|
67
84
|
char tmp[64];
|
85
|
+
|
68
86
|
memcpy(tmp, HTTP_PREFIX, HTTP_PREFIX_LEN);
|
69
87
|
|
70
88
|
for(i = ARRAY_SIZE(common_http_fields); --i >= 0; cf++) {
|
71
89
|
/* Rack doesn't like certain headers prefixed with "HTTP_" */
|
72
90
|
if (!strcmp("CONTENT_LENGTH", cf->name) ||
|
73
91
|
!strcmp("CONTENT_TYPE", cf->name)) {
|
74
|
-
cf->value =
|
92
|
+
cf->value = str_new_dd_freeze(cf->name, cf->len);
|
75
93
|
} else {
|
76
94
|
memcpy(tmp + HTTP_PREFIX_LEN, cf->name, cf->len + 1);
|
77
|
-
cf->value =
|
95
|
+
cf->value = str_new_dd_freeze(tmp, HTTP_PREFIX_LEN + cf->len);
|
78
96
|
}
|
79
|
-
|
80
|
-
rb_ary_push(mark_ary, cf->value);
|
97
|
+
rb_gc_register_mark_object(cf->value);
|
81
98
|
}
|
82
99
|
}
|
83
100
|
|
@@ -105,7 +122,7 @@ static VALUE uncommon_field(const char *field, size_t flen)
|
|
105
122
|
memcpy(RSTRING_PTR(f) + HTTP_PREFIX_LEN, field, flen);
|
106
123
|
assert(*(RSTRING_PTR(f) + RSTRING_LEN(f)) == '\0' &&
|
107
124
|
"string didn't end with \\0"); /* paranoia */
|
108
|
-
return
|
125
|
+
return HASH_ASET_DEDUPE ? f : str_dd_freeze(f);
|
109
126
|
}
|
110
127
|
|
111
128
|
#endif /* common_field_optimization_h */
|