unicorn 4.8.0 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/.document +0 -1
  3. data/.gitattributes +5 -0
  4. data/.gitignore +2 -2
  5. data/.manifest +17 -21
  6. data/.olddoc.yml +25 -0
  7. data/Application_Timeouts +7 -7
  8. data/CONTRIBUTORS +6 -2
  9. data/DESIGN +2 -4
  10. data/Documentation/.gitignore +1 -3
  11. data/Documentation/unicorn.1 +222 -0
  12. data/Documentation/unicorn_rails.1 +207 -0
  13. data/FAQ +23 -6
  14. data/GIT-VERSION-FILE +1 -1
  15. data/GIT-VERSION-GEN +1 -1
  16. data/GNUmakefile +138 -92
  17. data/HACKING +10 -32
  18. data/ISSUES +80 -19
  19. data/KNOWN_ISSUES +18 -18
  20. data/LATEST +23 -27
  21. data/LICENSE +2 -2
  22. data/Links +24 -22
  23. data/NEWS +823 -0
  24. data/PHILOSOPHY +0 -6
  25. data/README +49 -48
  26. data/Rakefile +0 -44
  27. data/SIGNALS +2 -2
  28. data/Sandbox +11 -10
  29. data/TODO +0 -2
  30. data/TUNING +30 -9
  31. data/archive/.gitignore +3 -0
  32. data/archive/slrnpull.conf +4 -0
  33. data/bin/unicorn +4 -2
  34. data/bin/unicorn_rails +3 -3
  35. data/examples/big_app_gc.rb +1 -1
  36. data/examples/init.sh +36 -8
  37. data/examples/logrotate.conf +17 -2
  38. data/examples/nginx.conf +14 -14
  39. data/examples/unicorn.conf.minimal.rb +2 -2
  40. data/examples/unicorn.conf.rb +14 -6
  41. data/examples/unicorn.socket +11 -0
  42. data/examples/unicorn@.service +40 -0
  43. data/ext/unicorn_http/c_util.h +5 -13
  44. data/ext/unicorn_http/common_field_optimization.h +22 -5
  45. data/ext/unicorn_http/epollexclusive.h +124 -0
  46. data/ext/unicorn_http/ext_help.h +0 -44
  47. data/ext/unicorn_http/extconf.rb +32 -5
  48. data/ext/unicorn_http/global_variables.h +2 -2
  49. data/ext/unicorn_http/httpdate.c +3 -2
  50. data/ext/unicorn_http/unicorn_http.c +926 -638
  51. data/ext/unicorn_http/unicorn_http.rl +159 -170
  52. data/ext/unicorn_http/unicorn_http_common.rl +1 -1
  53. data/lib/unicorn/configurator.rb +110 -46
  54. data/lib/unicorn/const.rb +2 -25
  55. data/lib/unicorn/http_request.rb +110 -31
  56. data/lib/unicorn/http_response.rb +17 -31
  57. data/lib/unicorn/http_server.rb +272 -180
  58. data/lib/unicorn/launcher.rb +1 -1
  59. data/lib/unicorn/oob_gc.rb +16 -6
  60. data/lib/unicorn/select_waiter.rb +6 -0
  61. data/lib/unicorn/socket_helper.rb +58 -78
  62. data/lib/unicorn/stream_input.rb +8 -7
  63. data/lib/unicorn/tee_input.rb +16 -11
  64. data/lib/unicorn/tmpio.rb +10 -6
  65. data/lib/unicorn/util.rb +5 -4
  66. data/lib/unicorn/version.rb +1 -1
  67. data/lib/unicorn/worker.rb +36 -23
  68. data/lib/unicorn.rb +64 -44
  69. data/man/man1/unicorn.1 +124 -122
  70. data/man/man1/unicorn_rails.1 +113 -127
  71. data/t/.gitignore +0 -1
  72. data/t/GNUmakefile +3 -80
  73. data/t/README +4 -4
  74. data/t/t0002-parser-error.sh +3 -3
  75. data/t/t0011-active-unix-socket.sh +1 -1
  76. data/t/t0012-reload-empty-config.sh +2 -1
  77. data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
  78. data/t/t0301.ru +13 -0
  79. data/t/test-lib.sh +4 -3
  80. data/test/benchmark/README +14 -4
  81. data/test/benchmark/ddstream.ru +50 -0
  82. data/test/benchmark/readinput.ru +40 -0
  83. data/test/benchmark/uconnect.perl +66 -0
  84. data/test/exec/test_exec.rb +74 -20
  85. data/test/test_helper.rb +42 -33
  86. data/test/unit/test_ccc.rb +91 -0
  87. data/test/unit/test_droplet.rb +1 -1
  88. data/test/unit/test_http_parser.rb +49 -19
  89. data/test/unit/test_http_parser_ng.rb +98 -115
  90. data/test/unit/test_request.rb +11 -11
  91. data/test/unit/test_response.rb +31 -19
  92. data/test/unit/test_server.rb +89 -15
  93. data/test/unit/test_signals.rb +9 -9
  94. data/test/unit/test_socket_helper.rb +16 -12
  95. data/test/unit/test_tee_input.rb +10 -0
  96. data/test/unit/test_upload.rb +10 -15
  97. data/test/unit/test_util.rb +32 -6
  98. data/test/unit/test_waiter.rb +34 -0
  99. data/unicorn.gemspec +28 -23
  100. data/unicorn_1 +1 -0
  101. data/unicorn_rails_1 +1 -0
  102. metadata +68 -134
  103. data/.wrongdoc.yml +0 -10
  104. data/ChangeLog +0 -4861
  105. data/Documentation/GNUmakefile +0 -30
  106. data/Documentation/unicorn.1.txt +0 -178
  107. data/Documentation/unicorn_rails.1.txt +0 -175
  108. data/examples/git.ru +0 -13
  109. data/lib/unicorn/app/exec_cgi.rb +0 -154
  110. data/lib/unicorn/app/inetd.rb +0 -109
  111. data/lib/unicorn/ssl_client.rb +0 -11
  112. data/lib/unicorn/ssl_configurator.rb +0 -104
  113. data/lib/unicorn/ssl_server.rb +0 -42
  114. data/local.mk.sample +0 -59
  115. data/script/isolate_for_tests +0 -32
  116. data/t/hijack.ru +0 -42
  117. data/t/sslgen.sh +0 -71
  118. data/t/t0016-trust-x-forwarded-false.sh +0 -30
  119. data/t/t0017-trust-x-forwarded-true.sh +0 -30
  120. data/t/t0200-rack-hijack.sh +0 -27
  121. data/t/t0600-https-server-basic.sh +0 -48
  122. data/test/unit/test_http_parser_xftrust.rb +0 -38
  123. data/test/unit/test_sni_hostnames.rb +0 -47
@@ -1,208 +1,187 @@
1
- .TH UNICORN_RAILS 1 "September 17, 2009" "Unicorn User Manual"
1
+ .TH "UNICORN_RAILS" "1" "September 17, 2009" "Unicorn User Manual" ""
2
+ .hy
2
3
  .SH NAME
3
4
  .PP
4
- unicorn_rails - a script/server-like command to launch the Unicorn
5
- HTTP server
5
+ unicorn_rails \- unicorn launcher for Rails 1.x and 2.x users
6
6
  .SH SYNOPSIS
7
7
  .PP
8
- unicorn_rails [-c CONFIG_FILE] [-E RAILS_ENV] [-D] [RACKUP_FILE]
8
+ unicorn_rails [\-c CONFIG_FILE] [\-E RAILS_ENV] [\-D] [RACKUP_FILE]
9
9
  .SH DESCRIPTION
10
10
  .PP
11
- A rackup(1)-like command to launch Rails applications using
12
- Unicorn.
13
- It is expected to be started in your Rails application root
14
- (RAILS_ROOT), but the \[lq]working_directory\[rq] directive may be
15
- used in the CONFIG_FILE.
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).
16
14
  .PP
17
- It is designed to help Rails 1.x and 2.y users transition to Rack,
18
- but it is NOT needed for Rails 3 applications.
19
- Rails 3 users are encouraged to use unicorn(1) instead of
20
- unicorn_rails(1).
21
- Users of Rails 1.x/2.y may also use unicorn(1) instead of
22
- unicorn_rails(1).
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.
23
17
  .PP
24
- The outward interface resembles rackup(1), the internals and
25
- default middleware loading is designed like the
26
- \f[B]script/server\f[] command distributed with Rails.
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.
27
21
  .PP
28
- While Unicorn takes a myriad of command-line options for
29
- compatibility with ruby(1) and rackup(1), it is recommended to
30
- stick to the few command-line options specified in the SYNOPSIS and
31
- use the CONFIG_FILE as much as possible.
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.
32
26
  .SH UNICORN OPTIONS
33
27
  .TP
34
- .B -c, --config-file CONFIG_FILE
35
- Path to the Unicorn-specific config file.
36
- The config file is implemented as a Ruby DSL, so Ruby code may
37
- executed.
38
- See the RDoc/ri for the \f[I]Unicorn::Configurator\f[] class for
39
- the full list of directives available from the DSL.
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.
40
33
  Using an absolute path for for CONFIG_FILE is recommended as it
41
34
  makes multiple instances of Unicorn easily distinguishable when
42
35
  viewing ps(1) output.
43
36
  .RS
44
37
  .RE
45
38
  .TP
46
- .B -D, --daemonize
47
- Run daemonized in the background.
48
- The process is detached from the controlling terminal and stdin is
49
- redirected to \[lq]/dev/null\[rq].
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".
50
42
  Unlike many common UNIX daemons, we do not chdir to "/" upon
51
43
  daemonization to allow more control over the startup/upgrade
52
44
  process.
53
- Unless specified in the CONFIG_FILE, stderr and stdout will also be
54
- redirected to \[lq]/dev/null\[rq].
45
+ Unless specified in the CONFIG_FILE, stderr and stdout will
46
+ also be redirected to "/dev/null".
55
47
  Daemonization will \f[I]skip\f[] loading of the
56
- \f[I]Rails::Rack::LogTailer\f[] middleware under Rails >= 2.3.x.
48
+ \f[I]Rails::Rack::LogTailer\f[]
49
+ middleware under Rails >= 2.3.x.
57
50
  By default, unicorn_rails(1) will create a PID file in
58
- \f[I]"RAILS_ROOT/tmp/pids/unicorn.pid"\f[].
59
- You may override this by specifying the \[lq]pid\[rq] directive to
60
- override this Unicorn config file.
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.
61
53
  .RS
62
54
  .RE
63
55
  .TP
64
- .B -E, --env RAILS_ENV
65
- Run under the given RAILS_ENV.
66
- This sets the RAILS_ENV environment variable.
67
- Acceptable values are exactly those you expect in your Rails
68
- application, typically \[lq]development\[rq] or
69
- \[lq]production\[rq].
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".
70
60
  .RS
71
61
  .RE
72
62
  .TP
73
- .B -l, --listen ADDRESS
74
- Listens on a given ADDRESS.
75
- ADDRESS may be in the form of HOST:PORT or PATH, HOST:PORT is taken
76
- to mean a TCP socket and PATH is meant to be a path to a UNIX
77
- domain socket.
78
- Defaults to \[lq]0.0.0.0:8080\[rq] (all addresses on TCP port
79
- 8080).
80
- For production deployments, specifying the \[lq]listen\[rq]
81
- directive in CONFIG_FILE is recommended as it allows fine-tuning of
82
- socket options.
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.
83
71
  .RS
84
72
  .RE
85
73
  .SH RACKUP COMPATIBILITY OPTIONS
86
74
  .TP
87
- .B -o, --host HOST
75
+ .B \-o, \-\-host HOST
88
76
  Listen on a TCP socket belonging to HOST, default is
89
- \[lq]0.0.0.0\[rq] (all addresses).
90
- If specified multiple times on the command-line, only the
91
- last-specified value takes effect.
92
- This option only exists for compatibility with the rackup(1)
93
- command, use of \[lq]-l\[rq]/\[lq]--listen\[rq] switch is
94
- recommended instead.
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.
95
82
  .RS
96
83
  .RE
97
84
  .TP
98
- .B -p, --port PORT
85
+ .B \-p, \-\-port PORT
99
86
  Listen on the specified TCP PORT, default is 8080.
100
- If specified multiple times on the command-line, only the
101
- last-specified value takes effect.
102
- This option only exists for compatibility with the rackup(1)
103
- command, use of \[lq]-l\[rq]/\[lq]--listen\[rq] switch is
104
- recommended instead.
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.
105
91
  .RS
106
92
  .RE
107
93
  .TP
108
- .B --path PATH
109
- Mounts the Rails application at the given PATH (instead of
110
- \[lq]/\[rq]).
94
+ .B \-\-path PATH
95
+ Mounts the Rails application at the given PATH (instead of "/").
111
96
  This is equivalent to setting the RAILS_RELATIVE_URL_ROOT
112
- environment variable.
113
- This is only supported under Rails 2.3 or later at the moment.
97
+ environment variable. This is only supported under Rails 2.3
98
+ or later at the moment.
114
99
  .RS
115
100
  .RE
116
101
  .SH RUBY OPTIONS
117
102
  .TP
118
- .B -e, --eval LINE
119
- Evaluate a LINE of Ruby code.
120
- This evaluation happens immediately as the command-line is being
121
- parsed.
103
+ .B \-e, \-\-eval LINE
104
+ Evaluate a LINE of Ruby code. This evaluation happens
105
+ immediately as the command\-line is being parsed.
122
106
  .RS
123
107
  .RE
124
108
  .TP
125
- .B -d, --debug
109
+ .B \-d, \-\-debug
126
110
  Turn on debug mode, the $DEBUG variable is set to true.
127
111
  For Rails >= 2.3.x, this loads the \f[I]Rails::Rack::Debugger\f[]
128
112
  middleware.
129
113
  .RS
130
114
  .RE
131
115
  .TP
132
- .B -w, --warn
116
+ .B \-w, \-\-warn
133
117
  Turn on verbose warnings, the $VERBOSE variable is set to true.
134
118
  .RS
135
119
  .RE
136
120
  .TP
137
- .B -I, --include PATH
138
- specify $LOAD_PATH.
139
- PATH will be prepended to $LOAD_PATH.
140
- The \[aq]:\[aq] character may be used to delimit multiple
141
- directories.
142
- This directive may be used more than once.
143
- Modifications to $LOAD_PATH take place immediately and in the order
144
- they were specified on the command-line.
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.
145
127
  .RS
146
128
  .RE
147
129
  .TP
148
- .B -r, --require LIBRARY
149
- require a specified LIBRARY before executing the application.
150
- The "require" statement will be executed immediately and in the
151
- order they were specified on the command-line.
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.
152
134
  .RS
153
135
  .RE
154
136
  .SH RACKUP FILE
155
137
  .PP
156
- This defaults to "config.ru" in RAILS_ROOT.
157
- It should be the same file used by rackup(1) and other Rack
158
- launchers, it uses the \f[I]Rack::Builder\f[] DSL.
159
- Unlike many other Rack applications, RACKUP_FILE is completely
160
- \f[I]optional\f[] for Rails, but may be used to disable some of the
161
- default middleware for performance.
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.
162
143
  .PP
163
- Embedded command-line options are mostly parsed for compatibility
144
+ Embedded command\-line options are mostly parsed for compatibility
164
145
  with rackup(1) but strongly discouraged.
165
146
  .SH ENVIRONMENT VARIABLES
166
147
  .PP
167
- The RAILS_ENV variable is set by the aforementioned -E switch.
168
- The RAILS_RELATIVE_URL_ROOT is set by the aforementioned --path
169
- switch.
170
- Either of these variables may also be set in the shell or the
171
- Unicorn CONFIG_FILE.
172
- All application or library-specific environment variables (e.g.
173
- TMPDIR, RAILS_ASSET_ID) may always be set in the Unicorn
174
- CONFIG_FILE in addition to the spawning shell.
175
- When transparently upgrading Unicorn, all environment variables set
176
- in the old master process are inherited by the new master process.
177
- Unicorn only uses (and will overwrite) the UNICORN_FD environment
178
- variable internally when doing transparent upgrades.
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.
179
158
  .SH SIGNALS
180
159
  .PP
181
160
  The following UNIX signals may be sent to the master process:
182
161
  .IP \[bu] 2
183
- HUP - reload config file, app, and gracefully restart all workers
162
+ HUP \- reload config file, app, and gracefully restart all workers
184
163
  .IP \[bu] 2
185
- INT/TERM - quick shutdown, kills all workers immediately
164
+ INT/TERM \- quick shutdown, kills all workers immediately
186
165
  .IP \[bu] 2
187
- QUIT - graceful shutdown, waits for workers to finish their current
166
+ QUIT \- graceful shutdown, waits for workers to finish their current
188
167
  request before finishing.
189
168
  .IP \[bu] 2
190
- USR1 - reopen all logs owned by the master and all workers See
191
- Unicorn::Util.reopen_logs for what is considered a log.
169
+ USR1 \- reopen all logs owned by the master and all workers
170
+ See Unicorn::Util.reopen_logs for what is considered a log.
192
171
  .IP \[bu] 2
193
- USR2 - reexecute the running binary.
194
- A separate QUIT should be sent to the original process once the
195
- child is verified to be up and running.
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.
196
175
  .IP \[bu] 2
197
- WINCH - gracefully stops workers but keep the master running.
176
+ WINCH \- gracefully stops workers but keep the master running.
198
177
  This will only work for daemonized processes.
199
178
  .IP \[bu] 2
200
- TTIN - increment the number of worker processes by one
179
+ TTIN \- increment the number of worker processes by one
201
180
  .IP \[bu] 2
202
- TTOU - decrement the number of worker processes by one
181
+ TTOU \- decrement the number of worker processes by one
203
182
  .PP
204
- See the SIGNALS (http://unicorn.bogomips.org/SIGNALS.html) document
205
- for full description of all signals used by Unicorn.
183
+ See the SIGNALS (https://yhbt.net/unicorn/SIGNALS.html) document for
184
+ full description of all signals used by Unicorn.
206
185
  .SH SEE ALSO
207
186
  .IP \[bu] 2
208
187
  unicorn(1)
@@ -210,12 +189,19 @@ unicorn(1)
210
189
  \f[I]Rack::Builder\f[] ri/RDoc
211
190
  .IP \[bu] 2
212
191
  \f[I]Unicorn::Configurator\f[] ri/RDoc
192
+ .UR https://yhbt.net/unicorn/Unicorn/Configurator.html
193
+ .UE
213
194
  .IP \[bu] 2
214
- Unicorn RDoc (http://unicorn.bogomips.org/)
195
+ unicorn RDoc
196
+ .UR https://yhbt.net/unicorn/
197
+ .UE
215
198
  .IP \[bu] 2
216
- Rack RDoc (http://rack.rubyforge.org/doc/)
199
+ Rack RDoc
200
+ .UR https://www.rubydoc.info/github/rack/rack/
201
+ .UE
217
202
  .IP \[bu] 2
218
- Rackup HowTo (http://wiki.github.com/rack/rack/tutorial-rackup-howto)
203
+ Rackup HowTo
204
+ .UR https://github.com/rack/rack/wiki/(tutorial)-rackup-howto
205
+ .UE
219
206
  .SH AUTHORS
220
- The Unicorn Community <mongrel-unicorn@rubyforge.org>.
221
-
207
+ The Unicorn Community <unicorn-public@yhbt.net>.
data/t/.gitignore CHANGED
@@ -2,4 +2,3 @@
2
2
  /.dep+*
3
3
  /*.crt
4
4
  /*.key
5
- /ssl-stamp
data/t/GNUmakefile CHANGED
@@ -1,82 +1,5 @@
1
- # we can run tests in parallel with GNU make
1
+ # there used to be more, here, but we stopped relying on recursive make
2
2
  all::
3
+ $(MAKE) -C .. test-integration
3
4
 
4
- pid := $(shell echo $$PPID)
5
-
6
- RUBY = ruby
7
- RAKE = rake
8
- -include ../local.mk
9
- ifeq ($(RUBY_VERSION),)
10
- RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
11
- endif
12
-
13
- ifeq ($(RUBY_VERSION),)
14
- $(error unable to detect RUBY_VERSION)
15
- endif
16
-
17
- RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
18
- export RUBY_ENGINE
19
-
20
- isolate_libs := ../tmp/isolate/$(RUBY_ENGINE)-$(RUBY_VERSION).mk
21
- $(isolate_libs): ../script/isolate_for_tests
22
- @cd .. && $(RUBY) script/isolate_for_tests
23
- -include $(isolate_libs)
24
- MYLIBS := $(RUBYLIB):$(ISOLATE_LIBS)
25
-
26
- T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
27
-
28
- all:: $(T)
29
-
30
- # can't rely on "set -o pipefail" since we don't require bash or ksh93 :<
31
- t_pfx = trash/$@-$(RUBY_ENGINE)-$(RUBY_VERSION)
32
- TEST_OPTS =
33
- # TRACER = strace -f -o $(t_pfx).strace -s 100000
34
- # TRACER = /usr/bin/time -o $(t_pfx).time
35
-
36
- ifdef V
37
- ifeq ($(V),2)
38
- TEST_OPTS += --trace
39
- else
40
- TEST_OPTS += --verbose
41
- endif
42
- endif
43
-
44
- random_blob:
45
- dd if=/dev/urandom bs=1M count=30 of=$@.$(pid)
46
- mv $@.$(pid) $@
47
-
48
- ssl-stamp:
49
- ./sslgen.sh
50
- > $@
51
-
52
- $(T): random_blob ssl-stamp
53
-
54
- dependencies := socat curl
55
- deps := $(addprefix .dep+,$(dependencies))
56
- $(deps): dep_bin = $(lastword $(subst +, ,$@))
57
- $(deps):
58
- @which $(dep_bin) > $@.$(pid) 2>/dev/null || :
59
- @test -s $@.$(pid) || \
60
- { echo >&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit 1; }
61
- @mv $@.$(pid) $@
62
- dep: $(deps)
63
-
64
- test_prefix := $(CURDIR)/../test/$(RUBY_ENGINE)-$(RUBY_VERSION)
65
- $(test_prefix)/.stamp:
66
- $(MAKE) -C .. test-install
67
-
68
- $(T): export RUBY := $(RUBY)
69
- $(T): export RAKE := $(RAKE)
70
- $(T): export PATH := $(test_prefix)/bin:$(PATH)
71
- $(T): export RUBYLIB := $(test_prefix)/lib:$(MYLIBS)
72
- $(T): dep $(test_prefix)/.stamp trash/.gitignore
73
- $(TRACER) $(SHELL) $(SH_TEST_OPTS) $@ $(TEST_OPTS)
74
-
75
- trash/.gitignore:
76
- mkdir -p $(@D)
77
- echo '*' > $@
78
-
79
- clean:
80
- $(RM) -r trash/*
81
-
82
- .PHONY: $(T) clean
5
+ .PHONY: all
data/t/README CHANGED
@@ -10,17 +10,17 @@ comfortable writing integration tests with.
10
10
 
11
11
  == Requirements
12
12
 
13
- * {Ruby 1.8 or 1.9}[http://www.ruby-lang.org/] (duh!)
14
- * {GNU make}[http://www.gnu.org/software/make/]
13
+ * {Ruby 2.0.0+}[https://www.ruby-lang.org/en/] (duh!)
14
+ * {GNU make}[https://www.gnu.org/software/make/]
15
15
  * {socat}[http://www.dest-unreach.org/socat/]
16
- * {curl}[http://curl.haxx.se/]
16
+ * {curl}[https://curl.haxx.se/]
17
17
  * standard UNIX shell utilities (Bourne sh, awk, sed, grep, ...)
18
18
 
19
19
  We do not use bashisms or any non-portable, non-POSIX constructs
20
20
  in our shell code. We use the "pipefail" option if available and
21
21
  mainly test with {ksh}[http://kornshell.com/], but occasionally
22
22
  with {dash}[http://gondor.apana.org.au/~herbert/dash/] and
23
- {bash}[http://www.gnu.org/software/bash/], too.
23
+ {bash}[https://www.gnu.org/software/bash/], too.
24
24
 
25
25
  == Running Tests
26
26
 
@@ -42,7 +42,7 @@ t_begin "send a huge Request URI (REQUEST_PATH > (12 * 1024))" && {
42
42
  }
43
43
 
44
44
  t_begin "response should be a 414 (REQUEST_PATH)" && {
45
- grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
45
+ grep -F 'HTTP/1.1 414 ' $tmp
46
46
  }
47
47
 
48
48
  t_begin "send a huge Request URI (QUERY_STRING > (10 * 1024))" && {
@@ -63,7 +63,7 @@ t_begin "send a huge Request URI (QUERY_STRING > (10 * 1024))" && {
63
63
  }
64
64
 
65
65
  t_begin "response should be a 414 (QUERY_STRING)" && {
66
- grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
66
+ grep -F 'HTTP/1.1 414 ' $tmp
67
67
  }
68
68
 
69
69
  t_begin "send a huge Request URI (FRAGMENT > 1024)" && {
@@ -84,7 +84,7 @@ t_begin "send a huge Request URI (FRAGMENT > 1024)" && {
84
84
  }
85
85
 
86
86
  t_begin "response should be a 414 (FRAGMENT)" && {
87
- grep -F 'HTTP/1.1 414 Request-URI Too Long' $tmp
87
+ grep -F 'HTTP/1.1 414 ' $tmp
88
88
  }
89
89
 
90
90
  t_begin "server stderr should be clean" && check_stderr
@@ -52,7 +52,7 @@ t_begin "worker pid unchanged (again)" && {
52
52
  }
53
53
 
54
54
  t_begin "nuking the existing Unicorn succeeds" && {
55
- kill -9 $unicorn_pid $worker_pid
55
+ kill -9 $unicorn_pid
56
56
  while kill -0 $unicorn_pid
57
57
  do
58
58
  sleep 1
@@ -18,7 +18,8 @@ after_fork { |s,w| }
18
18
  next if key =~ %r{\Astd(?:err|out)_path\z}
19
19
  key = key.to_sym
20
20
  def_value = defaults[key]
21
- srv_value = srv.__send__(key)
21
+ srv_value = srv.respond_to?(key) ? srv.__send__(key)
22
+ : srv.instance_variable_get("@#{key}")
22
23
  fp << "#{key}|#{srv_value}|#{def_value}\\n"
23
24
  end
24
25
  }
@@ -0,0 +1,25 @@
1
+ #!/bin/sh
2
+ . ./test-lib.sh
3
+ t_plan 3 "-N / --no-default-middleware option not supported in config.ru"
4
+
5
+ t_begin "setup and start" && {
6
+ unicorn_setup
7
+ RACK_ENV=development unicorn -D -c $unicorn_config t0301.ru
8
+ unicorn_wait_start
9
+ }
10
+
11
+ t_begin "check switches parsed as expected and -N ignored for Rack::Lint" && {
12
+ debug=false
13
+ lint=
14
+ eval "$(curl -sf http://$listen/vars)"
15
+ test x"$debug" = xtrue
16
+ test x"$lint" != x
17
+ test -f "$lint"
18
+ }
19
+
20
+ t_begin "killing succeeds" && {
21
+ kill $unicorn_pid
22
+ check_stderr
23
+ }
24
+
25
+ t_done
data/t/t0301.ru ADDED
@@ -0,0 +1,13 @@
1
+ #\-N --debug
2
+ run(lambda do |env|
3
+ case env['PATH_INFO']
4
+ when '/vars'
5
+ b = "debug=#{$DEBUG.inspect}\n" \
6
+ "lint=#{caller.grep(%r{rack/lint\.rb})[0].split(':')[0]}\n"
7
+ end
8
+ h = {
9
+ 'Content-Length' => b.size.to_s,
10
+ 'Content-Type' => 'text/plain',
11
+ }
12
+ [ 200, h, [ b ] ]
13
+ end)
data/t/test-lib.sh CHANGED
@@ -94,7 +94,8 @@ check_stderr () {
94
94
  set +u
95
95
  _r_err=${1-${r_err}}
96
96
  set -u
97
- if grep -v $T $_r_err | grep -i Error
97
+ if grep -v $T $_r_err | grep -i Error | \
98
+ grep -v NameError.*Unicorn::Waiter
98
99
  then
99
100
  die "Errors found in $_r_err"
100
101
  elif grep SIGKILL $_r_err
@@ -106,8 +107,8 @@ check_stderr () {
106
107
  # unicorn_setup
107
108
  unicorn_setup () {
108
109
  eval $(unused_listen)
109
- port=$(expr $listen : '[^:]*:\([0-9]\+\)')
110
- host=$(expr $listen : '\([^:]*\):[0-9]\+')
110
+ port=$(expr $listen : '[^:]*:\([0-9]*\)')
111
+ host=$(expr $listen : '\([^:][^:]*\):[0-9][0-9]*')
111
112
 
112
113
  rtmpfiles unicorn_config pid r_err r_out fifo tmp ok
113
114
  cat > $unicorn_config <<EOF
@@ -42,9 +42,19 @@ The benchmark client is usually httperf.
42
42
  Another gentle reminder: performance with slow networks/clients
43
43
  is NOT our problem. That is the job of nginx (or similar).
44
44
 
45
+ == ddstream.ru
46
+
47
+ Standalone Rack app intended to show how BAD we are at slow clients.
48
+ See usage in comments.
49
+
50
+ == readinput.ru
51
+
52
+ Standalone Rack app intended to show how bad we are with slow uploaders.
53
+ See usage in comments.
54
+
45
55
  == Contributors
46
56
 
47
- This directory is maintained independently in the "benchmark" branch
48
- based against v0.1.0. Only changes to this directory (test/benchmarks)
49
- are committed to this branch although the master branch may merge this
50
- branch occassionaly.
57
+ This directory is intended to remain stable. Do not make changes
58
+ to benchmarking code which can change performance and invalidate
59
+ results across revisions. Instead, write new benchmarks and update
60
+ coments/documentation as necessary.
@@ -0,0 +1,50 @@
1
+ # This app is intended to test large HTTP responses with or without
2
+ # a fully-buffering reverse proxy such as nginx. Without a fully-buffering
3
+ # reverse proxy, unicorn will be unresponsive when client count exceeds
4
+ # worker_processes.
5
+ #
6
+ # To demonstrate how bad unicorn is at slowly reading clients:
7
+ #
8
+ # # in one terminal, start unicorn with one worker:
9
+ # unicorn -E none -l 127.0.0.1:8080 test/benchmark/ddstream.ru
10
+ #
11
+ # # in a different terminal, start more slow curl processes than
12
+ # # unicorn workers and watch time outputs
13
+ # curl --limit-rate 8K --trace-time -vsN http://127.0.0.1:8080/ >/dev/null &
14
+ # curl --limit-rate 8K --trace-time -vsN http://127.0.0.1:8080/ >/dev/null &
15
+ # wait
16
+ #
17
+ # The last client won't see a response until the first one is done reading
18
+ #
19
+ # nginx note: do not change the default "proxy_buffering" behavior.
20
+ # Setting "proxy_buffering off" prevents nginx from protecting unicorn.
21
+
22
+ # totally standalone rack app to stream a giant response
23
+ class BigResponse
24
+ def initialize(bs, count)
25
+ @buf = "#{bs.to_s(16)}\r\n#{' ' * bs}\r\n"
26
+ @count = count
27
+ @res = [ 200,
28
+ { 'Transfer-Encoding' => -'chunked', 'Content-Type' => 'text/plain' },
29
+ self
30
+ ]
31
+ end
32
+
33
+ # rack response body iterator
34
+ def each
35
+ (1..@count).each { yield @buf }
36
+ yield -"0\r\n\r\n"
37
+ end
38
+
39
+ # rack app entry endpoint
40
+ def call(_env)
41
+ @res
42
+ end
43
+ end
44
+
45
+ # default to a giant (128M) response because kernel socket buffers
46
+ # can be ridiculously large on some systems
47
+ bs = ENV['bs'] ? ENV['bs'].to_i : 65536
48
+ count = ENV['count'] ? ENV['count'].to_i : 2048
49
+ warn "serving response with bs=#{bs} count=#{count} (#{bs*count} bytes)"
50
+ run BigResponse.new(bs, count)