unicorn 4.8.3 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.document +0 -1
- data/.gitattributes +5 -0
- data/.gitignore +2 -2
- data/.manifest +15 -19
- data/.olddoc.yml +25 -0
- data/Application_Timeouts +7 -7
- data/CONTRIBUTORS +6 -2
- data/DESIGN +2 -4
- data/Documentation/.gitignore +1 -3
- data/Documentation/unicorn.1 +222 -0
- data/Documentation/unicorn_rails.1 +207 -0
- data/FAQ +23 -6
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +138 -92
- data/HACKING +5 -30
- data/ISSUES +73 -36
- data/KNOWN_ISSUES +18 -18
- data/LATEST +16 -22
- data/LICENSE +2 -2
- data/Links +24 -22
- data/NEWS +771 -0
- data/PHILOSOPHY +0 -6
- data/README +48 -42
- data/Rakefile +0 -44
- data/SIGNALS +2 -2
- data/Sandbox +11 -10
- data/TODO +0 -2
- data/TUNING +30 -9
- data/archive/slrnpull.conf +1 -1
- data/bin/unicorn +4 -2
- data/bin/unicorn_rails +3 -3
- data/examples/big_app_gc.rb +1 -1
- data/examples/init.sh +36 -8
- data/examples/logrotate.conf +17 -2
- data/examples/nginx.conf +14 -14
- data/examples/unicorn.conf.minimal.rb +2 -2
- data/examples/unicorn.conf.rb +14 -6
- data/examples/unicorn.socket +11 -0
- data/examples/unicorn@.service +40 -0
- data/ext/unicorn_http/c_util.h +5 -13
- data/ext/unicorn_http/common_field_optimization.h +22 -5
- data/ext/unicorn_http/epollexclusive.h +124 -0
- data/ext/unicorn_http/ext_help.h +0 -44
- data/ext/unicorn_http/extconf.rb +32 -5
- data/ext/unicorn_http/global_variables.h +2 -2
- data/ext/unicorn_http/httpdate.c +3 -2
- data/ext/unicorn_http/unicorn_http.c +926 -638
- data/ext/unicorn_http/unicorn_http.rl +159 -170
- data/ext/unicorn_http/unicorn_http_common.rl +1 -1
- data/lib/unicorn/configurator.rb +110 -46
- data/lib/unicorn/const.rb +2 -25
- data/lib/unicorn/http_request.rb +110 -31
- data/lib/unicorn/http_response.rb +17 -31
- data/lib/unicorn/http_server.rb +259 -179
- data/lib/unicorn/launcher.rb +1 -1
- data/lib/unicorn/oob_gc.rb +6 -6
- data/lib/unicorn/select_waiter.rb +6 -0
- data/lib/unicorn/socket_helper.rb +58 -78
- data/lib/unicorn/stream_input.rb +8 -7
- data/lib/unicorn/tee_input.rb +16 -11
- data/lib/unicorn/tmpio.rb +10 -6
- data/lib/unicorn/util.rb +5 -4
- data/lib/unicorn/version.rb +1 -1
- data/lib/unicorn/worker.rb +36 -23
- data/lib/unicorn.rb +64 -44
- data/man/man1/unicorn.1 +124 -112
- data/man/man1/unicorn_rails.1 +106 -107
- data/t/GNUmakefile +3 -76
- data/t/README +4 -4
- data/t/t0002-parser-error.sh +3 -3
- data/t/t0011-active-unix-socket.sh +1 -1
- data/t/t0012-reload-empty-config.sh +2 -1
- data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
- data/t/t0301.ru +13 -0
- data/t/test-lib.sh +4 -3
- 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 +74 -20
- data/test/test_helper.rb +42 -33
- data/test/unit/test_ccc.rb +91 -0
- data/test/unit/test_droplet.rb +1 -1
- data/test/unit/test_http_parser.rb +49 -19
- data/test/unit/test_http_parser_ng.rb +98 -115
- data/test/unit/test_request.rb +11 -11
- data/test/unit/test_response.rb +31 -19
- data/test/unit/test_server.rb +89 -15
- data/test/unit/test_signals.rb +9 -9
- data/test/unit/test_socket_helper.rb +16 -12
- data/test/unit/test_tee_input.rb +10 -0
- data/test/unit/test_upload.rb +10 -15
- data/test/unit/test_util.rb +32 -6
- data/test/unit/test_waiter.rb +34 -0
- data/unicorn.gemspec +28 -23
- data/unicorn_1 +1 -0
- data/unicorn_rails_1 +1 -0
- metadata +37 -58
- data/.wrongdoc.yml +0 -11
- data/ChangeLog +0 -5027
- data/Documentation/GNUmakefile +0 -30
- data/Documentation/unicorn.1.txt +0 -178
- data/Documentation/unicorn_rails.1.txt +0 -175
- data/examples/git.ru +0 -13
- data/lib/unicorn/app/exec_cgi.rb +0 -154
- data/lib/unicorn/app/inetd.rb +0 -109
- data/lib/unicorn/ssl_client.rb +0 -11
- data/lib/unicorn/ssl_configurator.rb +0 -104
- data/lib/unicorn/ssl_server.rb +0 -42
- data/local.mk.sample +0 -59
- data/script/isolate_for_tests +0 -31
- data/t/hijack.ru +0 -42
- data/t/t0016-trust-x-forwarded-false.sh +0 -30
- data/t/t0017-trust-x-forwarded-true.sh +0 -30
- data/t/t0200-rack-hijack.sh +0 -27
- data/test/unit/test_http_parser_xftrust.rb +0 -38
- data/test/unit/test_sni_hostnames.rb +0 -47
@@ -0,0 +1,207 @@
|
|
1
|
+
.TH "UNICORN_RAILS" "1" "September 17, 2009" "Unicorn User Manual" ""
|
2
|
+
.hy
|
3
|
+
.SH NAME
|
4
|
+
.PP
|
5
|
+
unicorn_rails \- unicorn launcher for Rails 1.x and 2.x users
|
6
|
+
.SH SYNOPSIS
|
7
|
+
.PP
|
8
|
+
unicorn_rails [\-c CONFIG_FILE] [\-E RAILS_ENV] [\-D] [RACKUP_FILE]
|
9
|
+
.SH DESCRIPTION
|
10
|
+
.PP
|
11
|
+
A rackup(1)\-like command to launch ancient Rails (2.x and earlier)
|
12
|
+
applications using Unicorn. Rails 3 (and later) support Rack natively,
|
13
|
+
so users are encouraged to use unicorn(1) instead of unicorn_rails(1).
|
14
|
+
.PP
|
15
|
+
It is expected to be started in your Rails application root (RAILS_ROOT),
|
16
|
+
but the "working_directory" directive may be used in the CONFIG_FILE.
|
17
|
+
.PP
|
18
|
+
The outward interface resembles rackup(1), the internals and default
|
19
|
+
middleware loading is designed like the \f[C]script/server\f[] command
|
20
|
+
distributed with Rails.
|
21
|
+
.PP
|
22
|
+
While Unicorn takes a myriad of command\-line options for compatibility
|
23
|
+
with ruby(1) and rackup(1), it is recommended to stick to the few
|
24
|
+
command\-line options specified in the SYNOPSIS and use the CONFIG_FILE
|
25
|
+
as much as possible.
|
26
|
+
.SH UNICORN OPTIONS
|
27
|
+
.TP
|
28
|
+
.B \-c, \-\-config\-file CONFIG_FILE
|
29
|
+
Path to the Unicorn\-specific config file. The config file is
|
30
|
+
implemented as a Ruby DSL, so Ruby code may executed.
|
31
|
+
See the RDoc/ri for the \f[I]Unicorn::Configurator\f[] class for the full
|
32
|
+
list of directives available from the DSL.
|
33
|
+
Using an absolute path for for CONFIG_FILE is recommended as it
|
34
|
+
makes multiple instances of Unicorn easily distinguishable when
|
35
|
+
viewing ps(1) output.
|
36
|
+
.RS
|
37
|
+
.RE
|
38
|
+
.TP
|
39
|
+
.B \-D, \-\-daemonize
|
40
|
+
Run daemonized in the background. The process is detached from
|
41
|
+
the controlling terminal and stdin is redirected to "/dev/null".
|
42
|
+
Unlike many common UNIX daemons, we do not chdir to "/" upon
|
43
|
+
daemonization to allow more control over the startup/upgrade
|
44
|
+
process.
|
45
|
+
Unless specified in the CONFIG_FILE, stderr and stdout will
|
46
|
+
also be redirected to "/dev/null".
|
47
|
+
Daemonization will \f[I]skip\f[] loading of the
|
48
|
+
\f[I]Rails::Rack::LogTailer\f[]
|
49
|
+
middleware under Rails >= 2.3.x.
|
50
|
+
By default, unicorn_rails(1) will create a PID file in
|
51
|
+
\f[I]"RAILS_ROOT/tmp/pids/unicorn.pid"\f[]. You may override this
|
52
|
+
by specifying the "pid" directive to override this Unicorn config file.
|
53
|
+
.RS
|
54
|
+
.RE
|
55
|
+
.TP
|
56
|
+
.B \-E, \-\-env RAILS_ENV
|
57
|
+
Run under the given RAILS_ENV. This sets the RAILS_ENV environment
|
58
|
+
variable. Acceptable values are exactly those you expect in your Rails
|
59
|
+
application, typically "development" or "production".
|
60
|
+
.RS
|
61
|
+
.RE
|
62
|
+
.TP
|
63
|
+
.B \-l, \-\-listen ADDRESS
|
64
|
+
Listens on a given ADDRESS. ADDRESS may be in the form of
|
65
|
+
HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
|
66
|
+
and PATH is meant to be a path to a UNIX domain socket.
|
67
|
+
Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080).
|
68
|
+
For production deployments, specifying the "listen" directive in
|
69
|
+
CONFIG_FILE is recommended as it allows fine\-tuning of socket
|
70
|
+
options.
|
71
|
+
.RS
|
72
|
+
.RE
|
73
|
+
.SH RACKUP COMPATIBILITY OPTIONS
|
74
|
+
.TP
|
75
|
+
.B \-o, \-\-host HOST
|
76
|
+
Listen on a TCP socket belonging to HOST, default is
|
77
|
+
"0.0.0.0" (all addresses).
|
78
|
+
If specified multiple times on the command\-line, only the
|
79
|
+
last\-specified value takes effect.
|
80
|
+
This option only exists for compatibility with the rackup(1) command,
|
81
|
+
use of "\-l"/"\-\-listen" switch is recommended instead.
|
82
|
+
.RS
|
83
|
+
.RE
|
84
|
+
.TP
|
85
|
+
.B \-p, \-\-port PORT
|
86
|
+
Listen on the specified TCP PORT, default is 8080.
|
87
|
+
If specified multiple times on the command\-line, only the last\-specified
|
88
|
+
value takes effect.
|
89
|
+
This option only exists for compatibility with the rackup(1) command,
|
90
|
+
use of "\-l"/"\-\-listen" switch is recommended instead.
|
91
|
+
.RS
|
92
|
+
.RE
|
93
|
+
.TP
|
94
|
+
.B \-\-path PATH
|
95
|
+
Mounts the Rails application at the given PATH (instead of "/").
|
96
|
+
This is equivalent to setting the RAILS_RELATIVE_URL_ROOT
|
97
|
+
environment variable. This is only supported under Rails 2.3
|
98
|
+
or later at the moment.
|
99
|
+
.RS
|
100
|
+
.RE
|
101
|
+
.SH RUBY OPTIONS
|
102
|
+
.TP
|
103
|
+
.B \-e, \-\-eval LINE
|
104
|
+
Evaluate a LINE of Ruby code. This evaluation happens
|
105
|
+
immediately as the command\-line is being parsed.
|
106
|
+
.RS
|
107
|
+
.RE
|
108
|
+
.TP
|
109
|
+
.B \-d, \-\-debug
|
110
|
+
Turn on debug mode, the $DEBUG variable is set to true.
|
111
|
+
For Rails >= 2.3.x, this loads the \f[I]Rails::Rack::Debugger\f[]
|
112
|
+
middleware.
|
113
|
+
.RS
|
114
|
+
.RE
|
115
|
+
.TP
|
116
|
+
.B \-w, \-\-warn
|
117
|
+
Turn on verbose warnings, the $VERBOSE variable is set to true.
|
118
|
+
.RS
|
119
|
+
.RE
|
120
|
+
.TP
|
121
|
+
.B \-I, \-\-include PATH
|
122
|
+
specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
|
123
|
+
The \[aq]:\[aq] character may be used to delimit multiple directories.
|
124
|
+
This directive may be used more than once. Modifications to
|
125
|
+
$LOAD_PATH take place immediately and in the order they were
|
126
|
+
specified on the command\-line.
|
127
|
+
.RS
|
128
|
+
.RE
|
129
|
+
.TP
|
130
|
+
.B \-r, \-\-require LIBRARY
|
131
|
+
require a specified LIBRARY before executing the application. The
|
132
|
+
"require" statement will be executed immediately and in the order
|
133
|
+
they were specified on the command\-line.
|
134
|
+
.RS
|
135
|
+
.RE
|
136
|
+
.SH RACKUP FILE
|
137
|
+
.PP
|
138
|
+
This defaults to "config.ru" in RAILS_ROOT. It should be the same
|
139
|
+
file used by rackup(1) and other Rack launchers, it uses the
|
140
|
+
\f[I]Rack::Builder\f[] DSL. Unlike many other Rack applications, RACKUP_FILE
|
141
|
+
is completely \f[I]optional\f[] for Rails, but may be used to disable
|
142
|
+
some of the default middleware for performance.
|
143
|
+
.PP
|
144
|
+
Embedded command\-line options are mostly parsed for compatibility
|
145
|
+
with rackup(1) but strongly discouraged.
|
146
|
+
.SH ENVIRONMENT VARIABLES
|
147
|
+
.PP
|
148
|
+
The RAILS_ENV variable is set by the aforementioned \-E switch. The
|
149
|
+
RAILS_RELATIVE_URL_ROOT is set by the aforementioned \-\-path switch.
|
150
|
+
Either of these variables may also be set in the shell or the Unicorn
|
151
|
+
CONFIG_FILE. All application or library\-specific environment variables
|
152
|
+
(e.g. TMPDIR, RAILS_ASSET_ID) may always be set in the Unicorn
|
153
|
+
CONFIG_FILE in addition to the spawning shell. When transparently
|
154
|
+
upgrading Unicorn, all environment variables set in the old master
|
155
|
+
process are inherited by the new master process. Unicorn only uses (and
|
156
|
+
will overwrite) the UNICORN_FD environment variable internally when
|
157
|
+
doing transparent upgrades.
|
158
|
+
.SH SIGNALS
|
159
|
+
.PP
|
160
|
+
The following UNIX signals may be sent to the master process:
|
161
|
+
.IP \[bu] 2
|
162
|
+
HUP \- reload config file, app, and gracefully restart all workers
|
163
|
+
.IP \[bu] 2
|
164
|
+
INT/TERM \- quick shutdown, kills all workers immediately
|
165
|
+
.IP \[bu] 2
|
166
|
+
QUIT \- graceful shutdown, waits for workers to finish their current
|
167
|
+
request before finishing.
|
168
|
+
.IP \[bu] 2
|
169
|
+
USR1 \- reopen all logs owned by the master and all workers
|
170
|
+
See Unicorn::Util.reopen_logs for what is considered a log.
|
171
|
+
.IP \[bu] 2
|
172
|
+
USR2 \- reexecute the running binary. A separate QUIT
|
173
|
+
should be sent to the original process once the child is verified to
|
174
|
+
be up and running.
|
175
|
+
.IP \[bu] 2
|
176
|
+
WINCH \- gracefully stops workers but keep the master running.
|
177
|
+
This will only work for daemonized processes.
|
178
|
+
.IP \[bu] 2
|
179
|
+
TTIN \- increment the number of worker processes by one
|
180
|
+
.IP \[bu] 2
|
181
|
+
TTOU \- decrement the number of worker processes by one
|
182
|
+
.PP
|
183
|
+
See the SIGNALS (https://yhbt.net/unicorn/SIGNALS.html) document for
|
184
|
+
full description of all signals used by Unicorn.
|
185
|
+
.SH SEE ALSO
|
186
|
+
.IP \[bu] 2
|
187
|
+
unicorn(1)
|
188
|
+
.IP \[bu] 2
|
189
|
+
\f[I]Rack::Builder\f[] ri/RDoc
|
190
|
+
.IP \[bu] 2
|
191
|
+
\f[I]Unicorn::Configurator\f[] ri/RDoc
|
192
|
+
.UR https://yhbt.net/unicorn/Unicorn/Configurator.html
|
193
|
+
.UE
|
194
|
+
.IP \[bu] 2
|
195
|
+
unicorn RDoc
|
196
|
+
.UR https://yhbt.net/unicorn/
|
197
|
+
.UE
|
198
|
+
.IP \[bu] 2
|
199
|
+
Rack RDoc
|
200
|
+
.UR https://www.rubydoc.info/github/rack/rack/
|
201
|
+
.UE
|
202
|
+
.IP \[bu] 2
|
203
|
+
Rackup HowTo
|
204
|
+
.UR https://github.com/rack/rack/wiki/(tutorial)-rackup-howto
|
205
|
+
.UE
|
206
|
+
.SH AUTHORS
|
207
|
+
The Unicorn Community <unicorn-public@yhbt.net>.
|
data/FAQ
CHANGED
@@ -1,12 +1,21 @@
|
|
1
1
|
= Frequently Asked Questions about Unicorn
|
2
2
|
|
3
|
-
===
|
3
|
+
=== Why is nginx getting ECONNRESET as a reverse proxy?
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
Request body data (commonly from POST and PUT requests) may not be
|
6
|
+
drained entirely by the application. This may happen when request
|
7
|
+
bodies are gzipped, as unicorn reads request body data lazily to avoid
|
8
|
+
overhead from bad requests.
|
9
|
+
|
10
|
+
Ref: https://yhbt.net/unicorn-public/FC91211E-FD32-432C-92FC-0318714C2170@zendesk.com/
|
11
|
+
|
12
|
+
=== Why aren't my Rails log files rotated when I use SIGUSR1?
|
13
|
+
|
14
|
+
The Rails autoflush_log option must remain disabled with multiprocess
|
15
|
+
servers such as unicorn. Buffering in userspace may cause lines to be
|
16
|
+
partially written and lead to corruption in the presence of multiple
|
17
|
+
processes. With reasonable amounts of logging, the performance impact
|
18
|
+
of autoflush_log should be negligible on Linux and other modern kernels.
|
10
19
|
|
11
20
|
=== Why are my redirects going to "http" URLs when my site uses https?
|
12
21
|
|
@@ -51,3 +60,11 @@ queue makes failover to a different machine more difficult.
|
|
51
60
|
|
52
61
|
See the TUNING and Unicorn::Configurator documents for more information
|
53
62
|
on :backlog-related topics.
|
63
|
+
|
64
|
+
=== I've installed Rack 1.1.x, why can't Unicorn load Rails (2.3.5)?
|
65
|
+
|
66
|
+
Rails 2.3.5 is not compatible with Rack 1.1.x. Unicorn is compatible
|
67
|
+
with both Rack 1.1.x and Rack 1.0.x, and RubyGems will load the latest
|
68
|
+
version of Rack installed on the system. Uninstalling the Rack 1.1.x
|
69
|
+
gem should solve gem loading issues with Rails 2.3.5. Rails 2.3.6
|
70
|
+
and later correctly support Rack 1.1.x.
|
data/GIT-VERSION-FILE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
GIT_VERSION =
|
1
|
+
GIT_VERSION = 6.1.0
|
data/GIT-VERSION-GEN
CHANGED
data/GNUmakefile
CHANGED
@@ -8,6 +8,9 @@ RUBY = ruby
|
|
8
8
|
RAKE = rake
|
9
9
|
RAGEL = ragel
|
10
10
|
RSYNC = rsync
|
11
|
+
OLDDOC = olddoc
|
12
|
+
RDOC = rdoc
|
13
|
+
INSTALL = install
|
11
14
|
|
12
15
|
GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
|
13
16
|
@./GIT-VERSION-GEN
|
@@ -23,11 +26,38 @@ endif
|
|
23
26
|
|
24
27
|
RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
29
|
+
# we should never package more than one ext to avoid DSO proliferation:
|
30
|
+
# https://udrepper.livejournal.com/8790.html
|
31
|
+
ext := $(firstword $(wildcard ext/*))
|
32
|
+
|
33
|
+
ragel: $(ext)/unicorn_http.c
|
34
|
+
|
35
|
+
rl_files := $(wildcard $(ext)/*.rl)
|
36
|
+
ragel: $(ext)/unicorn_http.c
|
37
|
+
$(ext)/unicorn_http.c: $(rl_files)
|
38
|
+
cd $(@D) && $(RAGEL) unicorn_http.rl -C $(RLFLAGS) -o $(@F)
|
39
|
+
ext_pfx := test/$(RUBY_ENGINE)-$(RUBY_VERSION)
|
40
|
+
tmp_bin := $(ext_pfx)/bin
|
41
|
+
ext_h := $(wildcard $(ext)/*/*.h $(ext)/*.h)
|
42
|
+
ext_src := $(sort $(wildcard $(ext)/*.c) $(ext_h) $(ext)/unicorn_http.c)
|
43
|
+
ext_pfx_src := $(addprefix $(ext_pfx)/,$(ext_src))
|
44
|
+
ext_dir := $(ext_pfx)/$(ext)
|
45
|
+
$(ext)/extconf.rb:
|
46
|
+
@>>$@
|
47
|
+
$(ext_dir) $(tmp_bin) man/man1 doc/man1 pkg t/trash:
|
48
|
+
@mkdir -p $@
|
49
|
+
$(ext_pfx)/$(ext)/%: $(ext)/% | $(ext_dir)
|
50
|
+
$(INSTALL) -m 644 $< $@
|
51
|
+
$(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb | $(ext_dir)
|
52
|
+
$(RM) -f $(@D)/*.o
|
53
|
+
cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
|
54
|
+
ext_sfx := _ext.$(DLEXT)
|
55
|
+
ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
|
56
|
+
$(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
|
57
|
+
$(MAKE) -C $(@D)
|
58
|
+
lib := $(CURDIR)/lib:$(CURDIR)/$(ext_pfx)/$(ext)
|
59
|
+
http build: $(ext_dl)
|
60
|
+
$(ext_pfx)/$(ext)/unicorn_http.c: ext/unicorn_http/unicorn_http.c
|
31
61
|
|
32
62
|
# dunno how to implement this as concisely in Ruby, and hell, I love awk
|
33
63
|
awk_slow := awk '/def test_/{print FILENAME"--"$$2".n"}' 2>/dev/null
|
@@ -39,43 +69,21 @@ T := $(filter-out $(slow_tests), $(wildcard test/*/test*.rb))
|
|
39
69
|
T_n := $(shell $(awk_slow) $(slow_tests))
|
40
70
|
T_log := $(subst .rb,$(log_suffix),$(T))
|
41
71
|
T_n_log := $(subst .n,$(log_suffix),$(T_n))
|
42
|
-
test_prefix = $(CURDIR)/test/$(RUBY_ENGINE)-$(RUBY_VERSION)
|
43
72
|
|
44
|
-
ext := ext/unicorn_http
|
45
|
-
c_files := $(ext)/unicorn_http.c $(ext)/httpdate.c $(wildcard $(ext)/*.h)
|
46
|
-
rl_files := $(wildcard $(ext)/*.rl)
|
47
73
|
base_bins := unicorn unicorn_rails
|
48
74
|
bins := $(addprefix bin/, $(base_bins))
|
49
75
|
man1_rdoc := $(addsuffix _1, $(base_bins))
|
50
76
|
man1_bins := $(addsuffix .1, $(base_bins))
|
51
77
|
man1_paths := $(addprefix man/man1/, $(man1_bins))
|
52
|
-
|
53
|
-
|
78
|
+
tmp_bins = $(addprefix $(tmp_bin)/, unicorn unicorn_rails)
|
79
|
+
pid := $(shell echo $$PPID)
|
54
80
|
|
55
|
-
|
56
|
-
$(
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
$(MAKE) -C $(@D)
|
62
|
-
lib/unicorn_http.$(DLEXT): $(ext)/unicorn_http.$(DLEXT)
|
63
|
-
@mkdir -p lib
|
64
|
-
install -m644 $< $@
|
65
|
-
http: lib/unicorn_http.$(DLEXT)
|
66
|
-
|
67
|
-
test-install: $(test_prefix)/.stamp
|
68
|
-
$(test_prefix)/.stamp: $(inst_deps)
|
69
|
-
mkdir -p $(test_prefix)/.ccache
|
70
|
-
tar cf - $(inst_deps) GIT-VERSION-GEN | \
|
71
|
-
(cd $(test_prefix) && tar xf -)
|
72
|
-
$(MAKE) -C $(test_prefix) clean
|
73
|
-
$(MAKE) -C $(test_prefix) http shebang RUBY="$(RUBY)"
|
74
|
-
> $@
|
75
|
-
|
76
|
-
# this is only intended to be run within $(test_prefix)
|
77
|
-
shebang: $(bins)
|
78
|
-
$(MRI) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $^
|
81
|
+
$(tmp_bin)/%: bin/% | $(tmp_bin)
|
82
|
+
$(INSTALL) -m 755 $< $@.$(pid)
|
83
|
+
$(MRI) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.$(pid)
|
84
|
+
mv $@.$(pid) $@
|
85
|
+
|
86
|
+
bins: $(tmp_bins)
|
79
87
|
|
80
88
|
t_log := $(T_log) $(T_n_log)
|
81
89
|
test: $(T) $(T_n)
|
@@ -84,13 +92,56 @@ test: $(T) $(T_n)
|
|
84
92
|
|
85
93
|
test-exec: $(wildcard test/exec/test_*.rb)
|
86
94
|
test-unit: $(wildcard test/unit/test_*.rb)
|
87
|
-
$(slow_tests): $(
|
95
|
+
$(slow_tests): $(ext_dl)
|
88
96
|
@$(MAKE) $(shell $(awk_slow) $@)
|
89
97
|
|
90
|
-
|
91
|
-
|
98
|
+
# ensure we can require just the HTTP parser without the rest of unicorn
|
99
|
+
test-require: $(ext_dl)
|
100
|
+
$(RUBY) --disable-gems -I$(ext_pfx)/$(ext) -runicorn_http -e Unicorn
|
101
|
+
|
102
|
+
test_prereq := $(tmp_bins) $(ext_dl)
|
103
|
+
|
104
|
+
SH_TEST_OPTS =
|
105
|
+
ifdef V
|
106
|
+
ifeq ($(V),2)
|
107
|
+
SH_TEST_OPTS += --trace
|
108
|
+
else
|
109
|
+
SH_TEST_OPTS += --verbose
|
110
|
+
endif
|
111
|
+
endif
|
92
112
|
|
93
|
-
|
113
|
+
# do we trust Ruby behavior to be stable? some tests are
|
114
|
+
# (mostly) POSIX sh (not bash or ksh93, so no "set -o pipefail"
|
115
|
+
# TRACER = strace -f -o $(t_pfx).strace -s 100000
|
116
|
+
# TRACER = /usr/bin/time -o $(t_pfx).time
|
117
|
+
t_pfx = trash/$@-$(RUBY_ENGINE)-$(RUBY_VERSION)
|
118
|
+
T_sh = $(wildcard t/t[0-9][0-9][0-9][0-9]-*.sh)
|
119
|
+
$(T_sh): export RUBY := $(RUBY)
|
120
|
+
$(T_sh): export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
|
121
|
+
$(T_sh): export RUBYLIB := $(lib):$(RUBYLIB)
|
122
|
+
$(T_sh): dep $(test_prereq) t/random_blob t/trash/.gitignore
|
123
|
+
cd t && $(TRACER) $(SHELL) $(SH_TEST_OPTS) $(@F) $(TEST_OPTS)
|
124
|
+
|
125
|
+
t/trash/.gitignore : | t/trash
|
126
|
+
echo '*' >$@
|
127
|
+
|
128
|
+
dependencies := socat curl
|
129
|
+
deps := $(addprefix t/.dep+,$(dependencies))
|
130
|
+
$(deps): dep_bin = $(lastword $(subst +, ,$@))
|
131
|
+
$(deps):
|
132
|
+
@which $(dep_bin) > $@.$(pid) 2>/dev/null || :
|
133
|
+
@test -s $@.$(pid) || \
|
134
|
+
{ echo >&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit 1; }
|
135
|
+
@mv $@.$(pid) $@
|
136
|
+
dep: $(deps)
|
137
|
+
|
138
|
+
t/random_blob:
|
139
|
+
dd if=/dev/urandom bs=1M count=30 of=$@.$(pid)
|
140
|
+
mv $@.$(pid) $@
|
141
|
+
|
142
|
+
test-integration: $(T_sh)
|
143
|
+
|
144
|
+
check: test-require test test-integration
|
94
145
|
test-all: check
|
95
146
|
|
96
147
|
TEST_OPTS = -v
|
@@ -119,21 +170,20 @@ run_test = $(quiet_pre) \
|
|
119
170
|
|
120
171
|
%.n: arg = $(subst .n,,$(subst --, -n ,$@))
|
121
172
|
%.n: t = $(subst .n,$(log_suffix),$@)
|
122
|
-
%.n: export PATH := $(
|
123
|
-
%.n: export RUBYLIB := $(
|
124
|
-
%.n: $(
|
173
|
+
%.n: export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
|
174
|
+
%.n: export RUBYLIB := $(lib):$(RUBYLIB)
|
175
|
+
%.n: $(test_prereq)
|
125
176
|
$(run_test)
|
126
177
|
|
127
178
|
$(T): arg = $@
|
128
179
|
$(T): t = $(subst .rb,$(log_suffix),$@)
|
129
|
-
$(T): export PATH := $(
|
130
|
-
$(T): export RUBYLIB := $(
|
131
|
-
$(T): $(
|
180
|
+
$(T): export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
|
181
|
+
$(T): export RUBYLIB := $(lib):$(RUBYLIB)
|
182
|
+
$(T): $(test_prereq)
|
132
183
|
$(run_test)
|
133
184
|
|
134
185
|
install: $(bins) $(ext)/unicorn_http.c
|
135
186
|
$(prep_setup_rb)
|
136
|
-
$(RM) lib/unicorn_http.$(DLEXT)
|
137
187
|
$(RM) -r .install-tmp
|
138
188
|
mkdir .install-tmp
|
139
189
|
cp -p bin/* .install-tmp
|
@@ -148,71 +198,68 @@ prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
|
|
148
198
|
|
149
199
|
clean:
|
150
200
|
-$(MAKE) -C $(ext) clean
|
151
|
-
|
152
|
-
$(RM) $(ext)/Makefile lib/unicorn_http.$(DLEXT)
|
201
|
+
$(RM) $(ext)/Makefile
|
153
202
|
$(RM) $(setup_rb_files) $(t_log)
|
154
|
-
$(RM) -r $(
|
203
|
+
$(RM) -r $(ext_pfx) man t/trash
|
204
|
+
$(RM) $(html1)
|
205
|
+
|
206
|
+
man1 := $(addprefix Documentation/, unicorn.1 unicorn_rails.1)
|
207
|
+
html1 := $(addsuffix .html, $(man1))
|
208
|
+
man : $(man1) | man/man1
|
209
|
+
$(INSTALL) -m 644 $(man1) man/man1
|
210
|
+
|
211
|
+
html : $(html1) | doc/man1
|
212
|
+
$(INSTALL) -m 644 $(html1) doc/man1
|
155
213
|
|
156
|
-
|
157
|
-
$(
|
214
|
+
%.1.html: %.1
|
215
|
+
$(OLDDOC) man2html -o $@ ./$<
|
158
216
|
|
159
|
-
pkg_extra := GIT-VERSION-FILE lib/unicorn/version.rb
|
217
|
+
pkg_extra := GIT-VERSION-FILE lib/unicorn/version.rb LATEST NEWS \
|
160
218
|
$(ext)/unicorn_http.c $(man1_paths)
|
161
219
|
|
162
|
-
|
163
|
-
|
220
|
+
NEWS:
|
221
|
+
$(OLDDOC) prepare
|
164
222
|
|
165
|
-
.manifest:
|
223
|
+
.manifest: $(ext)/unicorn_http.c man NEWS
|
166
224
|
(git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
|
167
225
|
LC_ALL=C sort > $@+
|
168
226
|
cmp $@+ $@ || mv $@+ $@
|
169
227
|
$(RM) $@+
|
170
228
|
|
171
|
-
|
172
|
-
|
229
|
+
PLACEHOLDERS = $(man1_rdoc)
|
230
|
+
doc: .document $(ext)/unicorn_http.c man html .olddoc.yml $(PLACEHOLDERS)
|
173
231
|
find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
|
174
232
|
$(RM) -r doc
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
233
|
+
$(OLDDOC) prepare
|
234
|
+
$(RDOC) -f dark216
|
235
|
+
$(OLDDOC) merge
|
236
|
+
$(INSTALL) -m 644 COPYING doc/COPYING
|
237
|
+
$(INSTALL) -m 644 NEWS.atom.xml doc/NEWS.atom.xml
|
238
|
+
$(INSTALL) -m 644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
|
239
|
+
$(INSTALL) -m 644 $(man1_paths) doc/
|
179
240
|
tar cf - $$(git ls-files examples/) | (cd doc && tar xf -)
|
180
|
-
$(RM) $(man1_rdoc)
|
181
241
|
|
182
|
-
# publishes docs to
|
242
|
+
# publishes docs to https://yhbt.net/unicorn/
|
183
243
|
publish_doc:
|
184
244
|
-git set-file-times
|
185
245
|
$(MAKE) doc
|
186
|
-
find doc/images -type f | \
|
187
|
-
TZ=UTC xargs touch -d '1970-01-01 00:00:02' doc/rdoc.css
|
188
246
|
$(MAKE) doc_gz
|
189
247
|
chmod 644 $$(find doc -type f)
|
190
|
-
$(RSYNC) -av doc/
|
248
|
+
$(RSYNC) -av doc/ yhbt.net:/srv/yhbt/unicorn/ \
|
249
|
+
--exclude index.html* --exclude created.rid*
|
191
250
|
git ls-files | xargs touch
|
192
251
|
|
193
252
|
# Create gzip variants of the same timestamp as the original so nginx
|
194
253
|
# "gzip_static on" can serve the gzipped versions directly.
|
195
|
-
doc_gz: docs = $(shell find doc -type f ! -regex '
|
254
|
+
doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
|
196
255
|
doc_gz:
|
197
256
|
for i in $(docs); do \
|
198
257
|
gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
|
199
258
|
|
200
259
|
ifneq ($(VERSION),)
|
201
|
-
rfproject := mongrel
|
202
260
|
rfpackage := unicorn
|
203
261
|
pkggem := pkg/$(rfpackage)-$(VERSION).gem
|
204
262
|
pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
|
205
|
-
release_notes := release_notes-$(VERSION)
|
206
|
-
release_changes := release_changes-$(VERSION)
|
207
|
-
|
208
|
-
release-notes: $(release_notes)
|
209
|
-
release-changes: $(release_changes)
|
210
|
-
$(release_changes):
|
211
|
-
wrongdoc release_changes > $@+
|
212
|
-
$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
|
213
|
-
$(release_notes):
|
214
|
-
wrongdoc release_notes > $@+
|
215
|
-
$(VISUAL) $@+ && test -s $@+ && mv $@+ $@
|
216
263
|
|
217
264
|
# ensures we're actually on the tagged $(VERSION), only used for release
|
218
265
|
verify:
|
@@ -229,11 +276,10 @@ fix-perms:
|
|
229
276
|
gem: $(pkggem)
|
230
277
|
|
231
278
|
install-gem: $(pkggem)
|
232
|
-
gem install $(CURDIR)/$<
|
279
|
+
gem install --local $(CURDIR)/$<
|
233
280
|
|
234
|
-
$(pkggem): .manifest fix-perms
|
281
|
+
$(pkggem): .manifest fix-perms | pkg
|
235
282
|
gem build $(rfpackage).gemspec
|
236
|
-
mkdir -p pkg
|
237
283
|
mv $(@F) $@
|
238
284
|
|
239
285
|
$(pkgtgz): distdir = $(basename $@)
|
@@ -248,20 +294,20 @@ $(pkgtgz): .manifest fix-perms
|
|
248
294
|
|
249
295
|
package: $(pkgtgz) $(pkggem)
|
250
296
|
|
251
|
-
release: verify package
|
252
|
-
# make tgz release on RubyForge
|
253
|
-
rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
|
254
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
|
297
|
+
release: verify package
|
255
298
|
# push gem to Gemcutter
|
256
299
|
gem push $(pkggem)
|
257
|
-
# in case of gem downloads from RubyForge releases page
|
258
|
-
-rubyforge add_file \
|
259
|
-
$(rfproject) $(rfpackage) $(VERSION) $(pkggem)
|
260
|
-
$(RAKE) fm_update VERSION=$(VERSION)
|
261
300
|
else
|
262
301
|
gem install-gem: GIT-VERSION-FILE
|
263
302
|
$(MAKE) $@ VERSION=$(GIT_VERSION)
|
264
303
|
endif
|
265
304
|
|
266
|
-
|
267
|
-
|
305
|
+
$(PLACEHOLDERS):
|
306
|
+
echo olddoc_placeholder > $@
|
307
|
+
|
308
|
+
check-warnings:
|
309
|
+
@(for i in $$(git ls-files '*.rb' bin | grep -v '^setup\.rb$$'); \
|
310
|
+
do $(RUBY) --disable-gems -d -W2 -c \
|
311
|
+
$$i; done) | grep -v '^Syntax OK$$' || :
|
312
|
+
|
313
|
+
.PHONY: .FORCE-GIT-VERSION-FILE doc $(T) $(slow_tests) man $(T_sh) clean
|
data/HACKING
CHANGED
@@ -19,13 +19,6 @@ RubyGems.
|
|
19
19
|
Users of GNU-based systems (such as GNU/Linux) usually have GNU make
|
20
20
|
installed as "make" instead of "gmake".
|
21
21
|
|
22
|
-
Since we don't load RubyGems by default, loading Rack properly requires
|
23
|
-
setting up RUBYLIB to point to where Rack is located. Not loading
|
24
|
-
RubyGems drastically lowers the time to run the full test suite. You
|
25
|
-
may setup a "local.mk" file in the top-level working directory to setup
|
26
|
-
your RUBYLIB and any other environment variables. A "local.mk.sample"
|
27
|
-
file is provided for reference.
|
28
|
-
|
29
22
|
Running the entire test suite with 4 tests in parallel:
|
30
23
|
|
31
24
|
gmake -j4 check
|
@@ -57,25 +50,19 @@ programming experience will come in handy (or be learned) here.
|
|
57
50
|
|
58
51
|
=== Documentation
|
59
52
|
|
60
|
-
We use RDoc 2.5.x with Darkfish for documentation as much as possible,
|
61
|
-
if you're on Ruby 1.8 you want to install the latest "rdoc" gem. Due to
|
62
|
-
the lack of RDoc-to-manpage converters we know about, we're writing
|
63
|
-
manpages in Markdown and converting to troff/HTML with Pandoc.
|
64
|
-
|
65
53
|
Please wrap documentation at 72 characters-per-line or less (long URLs
|
66
54
|
are exempt) so it is comfortably readable from terminals.
|
67
55
|
|
68
56
|
When referencing mailing list posts, use
|
69
|
-
|
57
|
+
<tt>https://yhbt.net/unicorn-public/$MESSAGE_ID/</tt> if possible
|
70
58
|
since the Message-ID remains searchable even if a particular site
|
71
59
|
becomes unavailable.
|
72
60
|
|
73
61
|
=== Ruby/C Compatibility
|
74
62
|
|
75
|
-
We target Ruby
|
76
|
-
|
77
|
-
|
78
|
-
ability to use unlinked files.
|
63
|
+
We target C Ruby 2.0 and later. We need the Ruby
|
64
|
+
implementation to support fork, exec, pipe, UNIX signals, access to
|
65
|
+
integer file descriptors and ability to use unlinked files.
|
79
66
|
|
80
67
|
All of our C code is OS-independent and should run on compilers
|
81
68
|
supported by the versions of Ruby we target.
|
@@ -112,11 +99,6 @@ don't email the git mailing list or maintainer with Unicorn patches :)
|
|
112
99
|
|
113
100
|
== Building a Gem
|
114
101
|
|
115
|
-
In order to build the gem, you must install the following components:
|
116
|
-
|
117
|
-
* wrongdoc
|
118
|
-
* pandoc
|
119
|
-
|
120
102
|
You can build the Unicorn gem with the following command:
|
121
103
|
|
122
104
|
gmake gem
|
@@ -125,13 +107,6 @@ You can build the Unicorn gem with the following command:
|
|
125
107
|
|
126
108
|
It is easy to install the contents of your git working directory:
|
127
109
|
|
128
|
-
Via RubyGems
|
110
|
+
Via RubyGems
|
129
111
|
|
130
112
|
gmake install-gem
|
131
|
-
|
132
|
-
Without RubyGems (via setup.rb):
|
133
|
-
|
134
|
-
gmake install
|
135
|
-
|
136
|
-
It is not at all recommended to mix a RubyGems installation with an
|
137
|
-
installation done without RubyGems, however.
|