unicorn-maintained 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.CHANGELOG.old +25 -0
  3. data/.document +28 -0
  4. data/.gitattributes +5 -0
  5. data/.gitignore +25 -0
  6. data/.mailmap +26 -0
  7. data/.manifest +149 -0
  8. data/.olddoc.yml +25 -0
  9. data/Application_Timeouts +77 -0
  10. data/CONTRIBUTORS +39 -0
  11. data/COPYING +674 -0
  12. data/DESIGN +99 -0
  13. data/Documentation/.gitignore +3 -0
  14. data/Documentation/unicorn.1 +222 -0
  15. data/Documentation/unicorn_rails.1 +207 -0
  16. data/FAQ +70 -0
  17. data/GIT-VERSION-FILE +1 -0
  18. data/GIT-VERSION-GEN +39 -0
  19. data/GNUmakefile +317 -0
  20. data/HACKING +112 -0
  21. data/ISSUES +102 -0
  22. data/KNOWN_ISSUES +79 -0
  23. data/LATEST +1 -0
  24. data/LICENSE +67 -0
  25. data/Links +58 -0
  26. data/NEWS +1 -0
  27. data/PHILOSOPHY +139 -0
  28. data/README +156 -0
  29. data/Rakefile +16 -0
  30. data/SIGNALS +123 -0
  31. data/Sandbox +104 -0
  32. data/TODO +3 -0
  33. data/TUNING +119 -0
  34. data/archive/.gitignore +3 -0
  35. data/archive/slrnpull.conf +4 -0
  36. data/bin/unicorn +128 -0
  37. data/bin/unicorn_rails +209 -0
  38. data/examples/big_app_gc.rb +2 -0
  39. data/examples/echo.ru +26 -0
  40. data/examples/init.sh +102 -0
  41. data/examples/logger_mp_safe.rb +25 -0
  42. data/examples/logrotate.conf +44 -0
  43. data/examples/nginx.conf +156 -0
  44. data/examples/unicorn.conf.minimal.rb +13 -0
  45. data/examples/unicorn.conf.rb +110 -0
  46. data/examples/unicorn.socket +11 -0
  47. data/examples/unicorn@.service +40 -0
  48. data/ext/unicorn_http/CFLAGS +13 -0
  49. data/ext/unicorn_http/c_util.h +116 -0
  50. data/ext/unicorn_http/common_field_optimization.h +128 -0
  51. data/ext/unicorn_http/epollexclusive.h +128 -0
  52. data/ext/unicorn_http/ext_help.h +38 -0
  53. data/ext/unicorn_http/extconf.rb +39 -0
  54. data/ext/unicorn_http/global_variables.h +97 -0
  55. data/ext/unicorn_http/httpdate.c +91 -0
  56. data/ext/unicorn_http/unicorn_http.c +4334 -0
  57. data/ext/unicorn_http/unicorn_http.rl +1040 -0
  58. data/ext/unicorn_http/unicorn_http_common.rl +76 -0
  59. data/lib/unicorn/app/old_rails/static.rb +59 -0
  60. data/lib/unicorn/app/old_rails.rb +35 -0
  61. data/lib/unicorn/cgi_wrapper.rb +147 -0
  62. data/lib/unicorn/configurator.rb +748 -0
  63. data/lib/unicorn/const.rb +21 -0
  64. data/lib/unicorn/http_request.rb +201 -0
  65. data/lib/unicorn/http_response.rb +93 -0
  66. data/lib/unicorn/http_server.rb +859 -0
  67. data/lib/unicorn/launcher.rb +62 -0
  68. data/lib/unicorn/oob_gc.rb +81 -0
  69. data/lib/unicorn/preread_input.rb +33 -0
  70. data/lib/unicorn/select_waiter.rb +6 -0
  71. data/lib/unicorn/socket_helper.rb +185 -0
  72. data/lib/unicorn/stream_input.rb +151 -0
  73. data/lib/unicorn/tee_input.rb +131 -0
  74. data/lib/unicorn/tmpio.rb +33 -0
  75. data/lib/unicorn/util.rb +90 -0
  76. data/lib/unicorn/version.rb +1 -0
  77. data/lib/unicorn/worker.rb +165 -0
  78. data/lib/unicorn.rb +136 -0
  79. data/man/man1/unicorn.1 +222 -0
  80. data/man/man1/unicorn_rails.1 +207 -0
  81. data/setup.rb +1586 -0
  82. data/t/.gitignore +4 -0
  83. data/t/GNUmakefile +5 -0
  84. data/t/README +49 -0
  85. data/t/active-unix-socket.t +117 -0
  86. data/t/bin/unused_listen +40 -0
  87. data/t/broken-app.ru +12 -0
  88. data/t/client_body_buffer_size.ru +14 -0
  89. data/t/client_body_buffer_size.t +80 -0
  90. data/t/detach.ru +11 -0
  91. data/t/env.ru +3 -0
  92. data/t/fails-rack-lint.ru +5 -0
  93. data/t/heartbeat-timeout.ru +12 -0
  94. data/t/heartbeat-timeout.t +62 -0
  95. data/t/integration.ru +115 -0
  96. data/t/integration.t +356 -0
  97. data/t/lib.perl +258 -0
  98. data/t/listener_names.ru +4 -0
  99. data/t/my-tap-lib.sh +201 -0
  100. data/t/oob_gc.ru +17 -0
  101. data/t/oob_gc_path.ru +17 -0
  102. data/t/pid.ru +3 -0
  103. data/t/preread_input.ru +22 -0
  104. data/t/reload-bad-config.t +54 -0
  105. data/t/reopen-logs.ru +13 -0
  106. data/t/reopen-logs.t +39 -0
  107. data/t/t0008-back_out_of_upgrade.sh +110 -0
  108. data/t/t0009-broken-app.sh +56 -0
  109. data/t/t0010-reap-logging.sh +55 -0
  110. data/t/t0012-reload-empty-config.sh +86 -0
  111. data/t/t0013-rewindable-input-false.sh +24 -0
  112. data/t/t0013.ru +12 -0
  113. data/t/t0014-rewindable-input-true.sh +24 -0
  114. data/t/t0014.ru +12 -0
  115. data/t/t0015-configurator-internals.sh +25 -0
  116. data/t/t0020-at_exit-handler.sh +49 -0
  117. data/t/t0021-process_detach.sh +29 -0
  118. data/t/t0022-listener_names-preload_app.sh +32 -0
  119. data/t/t0300-no-default-middleware.sh +20 -0
  120. data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
  121. data/t/t0301.ru +13 -0
  122. data/t/t9001-oob_gc.sh +47 -0
  123. data/t/t9002-oob_gc-path.sh +75 -0
  124. data/t/test-lib.sh +125 -0
  125. data/t/winch_ttin.t +67 -0
  126. data/t/working_directory.t +94 -0
  127. data/test/aggregate.rb +15 -0
  128. data/test/benchmark/README +60 -0
  129. data/test/benchmark/dd.ru +18 -0
  130. data/test/benchmark/ddstream.ru +50 -0
  131. data/test/benchmark/readinput.ru +40 -0
  132. data/test/benchmark/stack.ru +8 -0
  133. data/test/benchmark/uconnect.perl +66 -0
  134. data/test/exec/README +5 -0
  135. data/test/exec/test_exec.rb +1029 -0
  136. data/test/test_helper.rb +306 -0
  137. data/test/unit/test_ccc.rb +91 -0
  138. data/test/unit/test_configurator.rb +175 -0
  139. data/test/unit/test_droplet.rb +28 -0
  140. data/test/unit/test_http_parser.rb +884 -0
  141. data/test/unit/test_http_parser_ng.rb +714 -0
  142. data/test/unit/test_request.rb +169 -0
  143. data/test/unit/test_server.rb +244 -0
  144. data/test/unit/test_signals.rb +188 -0
  145. data/test/unit/test_socket_helper.rb +159 -0
  146. data/test/unit/test_stream_input.rb +210 -0
  147. data/test/unit/test_tee_input.rb +303 -0
  148. data/test/unit/test_util.rb +131 -0
  149. data/test/unit/test_waiter.rb +34 -0
  150. data/unicorn.gemspec +48 -0
  151. metadata +275 -0
data/GNUmakefile ADDED
@@ -0,0 +1,317 @@
1
+ # use GNU Make to run tests in parallel, and without depending on RubyGems
2
+ all:: test
3
+
4
+ RLFLAGS = -G2
5
+
6
+ MRI = ruby
7
+ RUBY = ruby
8
+ RAKE = rake
9
+ RAGEL = ragel
10
+ RSYNC = rsync
11
+ OLDDOC = olddoc
12
+ RDOC = rdoc
13
+ INSTALL = install
14
+ PROVE = prove
15
+
16
+ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
17
+ @./GIT-VERSION-GEN
18
+ -include GIT-VERSION-FILE
19
+ -include local.mk
20
+ ruby_bin := $(shell which $(RUBY))
21
+ ifeq ($(DLEXT),) # "so" for Linux
22
+ DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts RbConfig::CONFIG["DLEXT"]')
23
+ endif
24
+ ifeq ($(RUBY_VERSION),)
25
+ RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
26
+ endif
27
+
28
+ RUBY_ENGINE := $(shell $(RUBY) -e 'puts((RUBY_ENGINE rescue "ruby"))')
29
+
30
+ # we should never package more than one ext to avoid DSO proliferation:
31
+ # https://udrepper.livejournal.com/8790.html
32
+ ext := $(firstword $(wildcard ext/*))
33
+
34
+ ragel: $(ext)/unicorn_http.c
35
+
36
+ rl_files := $(wildcard $(ext)/*.rl)
37
+ ragel: $(ext)/unicorn_http.c
38
+ $(ext)/unicorn_http.c: $(rl_files)
39
+ cd $(@D) && $(RAGEL) unicorn_http.rl -C $(RLFLAGS) -o $(@F)
40
+ ext_pfx := test/$(RUBY_ENGINE)-$(RUBY_VERSION)
41
+ tmp_bin := $(ext_pfx)/bin
42
+ ext_h := $(wildcard $(ext)/*/*.h $(ext)/*.h)
43
+ ext_src := $(sort $(wildcard $(ext)/*.c) $(ext_h) $(ext)/unicorn_http.c)
44
+ ext_pfx_src := $(addprefix $(ext_pfx)/,$(ext_src))
45
+ ext_dir := $(ext_pfx)/$(ext)
46
+ $(ext)/extconf.rb:
47
+ @>>$@
48
+ $(ext_dir) $(tmp_bin) man/man1 doc/man1 pkg t/trash:
49
+ @mkdir -p $@
50
+ $(ext_pfx)/$(ext)/%: $(ext)/% | $(ext_dir)
51
+ $(INSTALL) -m 644 $< $@
52
+ $(ext_pfx)/$(ext)/Makefile: $(ext)/extconf.rb | $(ext_dir)
53
+ $(RM) -f $(@D)/*.o
54
+ cd $(@D) && $(RUBY) $(CURDIR)/$(ext)/extconf.rb $(EXTCONF_ARGS)
55
+ ext_sfx := _ext.$(DLEXT)
56
+ ext_dl := $(ext_pfx)/$(ext)/$(notdir $(ext)_ext.$(DLEXT))
57
+ $(ext_dl): $(ext_src) $(ext_pfx_src) $(ext_pfx)/$(ext)/Makefile
58
+ $(MAKE) -C $(@D)
59
+ lib := $(CURDIR)/lib:$(CURDIR)/$(ext_pfx)/$(ext)
60
+ http build: $(ext_dl)
61
+ $(ext_pfx)/$(ext)/unicorn_http.c: ext/unicorn_http/unicorn_http.c
62
+
63
+ # dunno how to implement this as concisely in Ruby, and hell, I love awk
64
+ awk_slow := awk '/def test_/{print FILENAME"--"$$2".n"}' 2>/dev/null
65
+
66
+ slow_tests := test/unit/test_server.rb test/exec/test_exec.rb \
67
+ test/unit/test_signals.rb test/unit/test_upload.rb
68
+ log_suffix = .$(RUBY_ENGINE).$(RUBY_VERSION).log
69
+ T := $(filter-out $(slow_tests), $(wildcard test/*/test*.rb))
70
+ T_n := $(shell $(awk_slow) $(slow_tests))
71
+ T_log := $(subst .rb,$(log_suffix),$(T))
72
+ T_n_log := $(subst .n,$(log_suffix),$(T_n))
73
+
74
+ base_bins := unicorn unicorn_rails
75
+ bins := $(addprefix bin/, $(base_bins))
76
+ man1_rdoc := $(addsuffix _1, $(base_bins))
77
+ man1_bins := $(addsuffix .1, $(base_bins))
78
+ man1_paths := $(addprefix man/man1/, $(man1_bins))
79
+ tmp_bins = $(addprefix $(tmp_bin)/, unicorn unicorn_rails)
80
+ pid := $(shell echo $$PPID)
81
+
82
+ $(tmp_bin)/%: bin/% | $(tmp_bin)
83
+ $(INSTALL) -m 755 $< $@.$(pid)
84
+ $(MRI) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.$(pid)
85
+ mv $@.$(pid) $@
86
+
87
+ bins: $(tmp_bins)
88
+
89
+ t_log := $(T_log) $(T_n_log)
90
+ test: $(T) $(T_n) test-prove
91
+ @cat $(t_log) | $(MRI) test/aggregate.rb
92
+ @$(RM) $(t_log)
93
+
94
+ test-exec: $(wildcard test/exec/test_*.rb)
95
+ test-unit: $(wildcard test/unit/test_*.rb)
96
+ $(slow_tests): $(ext_dl)
97
+ @$(MAKE) $(shell $(awk_slow) $@)
98
+
99
+ # ensure we can require just the HTTP parser without the rest of unicorn
100
+ test-require: $(ext_dl)
101
+ $(RUBY) --disable-gems -I$(ext_pfx)/$(ext) -runicorn_http -e Unicorn
102
+
103
+ test_prereq := $(tmp_bins) $(ext_dl)
104
+
105
+ SH_TEST_OPTS =
106
+ ifdef V
107
+ ifeq ($(V),2)
108
+ SH_TEST_OPTS += --trace
109
+ else
110
+ SH_TEST_OPTS += --verbose
111
+ endif
112
+ endif
113
+
114
+ # do we trust Ruby behavior to be stable? some tests are
115
+ # (mostly) POSIX sh (not bash or ksh93, so no "set -o pipefail"
116
+ # TRACER = strace -f -o $(t_pfx).strace -s 100000
117
+ # TRACER = /usr/bin/time -o $(t_pfx).time
118
+ t_pfx = trash/$@-$(RUBY_ENGINE)-$(RUBY_VERSION)
119
+ T_sh = $(wildcard t/t[0-9][0-9][0-9][0-9]-*.sh)
120
+ $(T_sh): export RUBY := $(RUBY)
121
+ $(T_sh): export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
122
+ $(T_sh): export RUBYLIB := $(lib):$(RUBYLIB)
123
+ $(T_sh): dep $(test_prereq) t/random_blob t/trash/.gitignore
124
+ cd t && $(TRACER) $(SHELL) $(SH_TEST_OPTS) $(@F) $(TEST_OPTS)
125
+
126
+ t/trash/.gitignore : | t/trash
127
+ echo '*' >$@
128
+
129
+ dependencies := curl
130
+ deps := $(addprefix t/.dep+,$(dependencies))
131
+ $(deps): dep_bin = $(lastword $(subst +, ,$@))
132
+ $(deps):
133
+ @which $(dep_bin) > $@.$(pid) 2>/dev/null || :
134
+ @test -s $@.$(pid) || \
135
+ { echo >&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit 1; }
136
+ @mv $@.$(pid) $@
137
+ dep: $(deps)
138
+
139
+ t/random_blob:
140
+ dd if=/dev/urandom bs=1M count=30 of=$@.$(pid)
141
+ mv $@.$(pid) $@
142
+
143
+ test-integration: $(T_sh)
144
+
145
+ test-prove: t/random_blob
146
+ $(PROVE) -vw
147
+
148
+ check: test-require test test-integration
149
+ test-all: check
150
+
151
+ TEST_OPTS = -v
152
+ check_test = grep '0 failures, 0 errors' $(t) >/dev/null
153
+ ifndef V
154
+ quiet_pre = @echo '* $(arg)$(extra)';
155
+ quiet_post = >$(t) 2>&1 && $(check_test)
156
+ else
157
+ # we can't rely on -o pipefail outside of bash 3+,
158
+ # so we use a stamp file to indicate success and
159
+ # have rm fail if the stamp didn't get created
160
+ stamp = $@$(log_suffix).ok
161
+ quiet_pre = @echo $(RUBY) $(arg) $(TEST_OPTS); ! test -f $(stamp) && (
162
+ quiet_post = && > $(stamp) )2>&1 | tee $(t); \
163
+ rm $(stamp) 2>/dev/null && $(check_test)
164
+ endif
165
+
166
+ # not all systems have setsid(8), we need it because we spam signals
167
+ # stupidly in some tests...
168
+ rb_setsid := $(RUBY) -e 'Process.setsid' -e 'exec *ARGV'
169
+
170
+ # TRACER='strace -f -o $(t).strace -s 100000'
171
+ run_test = $(quiet_pre) \
172
+ $(rb_setsid) $(TRACER) $(RUBY) -w $(arg) $(TEST_OPTS) $(quiet_post) || \
173
+ (sed "s,^,$(extra): ," >&2 < $(t); exit 1)
174
+
175
+ %.n: arg = $(subst .n,,$(subst --, -n ,$@))
176
+ %.n: t = $(subst .n,$(log_suffix),$@)
177
+ %.n: export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
178
+ %.n: export RUBYLIB := $(lib):$(RUBYLIB)
179
+ %.n: $(test_prereq)
180
+ $(run_test)
181
+
182
+ $(T): arg = $@
183
+ $(T): t = $(subst .rb,$(log_suffix),$@)
184
+ $(T): export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
185
+ $(T): export RUBYLIB := $(lib):$(RUBYLIB)
186
+ $(T): $(test_prereq)
187
+ $(run_test)
188
+
189
+ install: $(bins) $(ext)/unicorn_http.c
190
+ $(prep_setup_rb)
191
+ $(RM) -r .install-tmp
192
+ mkdir .install-tmp
193
+ cp -p bin/* .install-tmp
194
+ $(RUBY) setup.rb all
195
+ $(RM) $^
196
+ mv .install-tmp/* bin/
197
+ $(RM) -r .install-tmp
198
+ $(prep_setup_rb)
199
+
200
+ setup_rb_files := .config InstalledFiles
201
+ prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
202
+
203
+ clean:
204
+ -$(MAKE) -C $(ext) clean
205
+ $(RM) $(ext)/Makefile
206
+ $(RM) $(setup_rb_files) $(t_log)
207
+ $(RM) -r $(ext_pfx) man t/trash
208
+ $(RM) $(html1)
209
+
210
+ man1 := $(addprefix Documentation/, unicorn.1 unicorn_rails.1)
211
+ html1 := $(addsuffix .html, $(man1))
212
+ man : $(man1) | man/man1
213
+ $(INSTALL) -m 644 $(man1) man/man1
214
+
215
+ html : $(html1) | doc/man1
216
+ $(INSTALL) -m 644 $(html1) doc/man1
217
+
218
+ %.1.html: %.1
219
+ $(OLDDOC) man2html -o $@ ./$<
220
+
221
+ pkg_extra := GIT-VERSION-FILE lib/unicorn/version.rb LATEST NEWS \
222
+ $(ext)/unicorn_http.c $(man1_paths)
223
+
224
+ NEWS:
225
+ $(OLDDOC) prepare
226
+
227
+ .manifest: $(ext)/unicorn_http.c man NEWS
228
+ (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
229
+ LC_ALL=C sort > $@+
230
+ cmp $@+ $@ || mv $@+ $@
231
+ $(RM) $@+
232
+
233
+ PLACEHOLDERS = $(man1_rdoc)
234
+ doc: .document $(ext)/unicorn_http.c man html .olddoc.yml $(PLACEHOLDERS)
235
+ find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
236
+ $(RM) -r doc
237
+ $(OLDDOC) prepare
238
+ $(RDOC) -f dark216
239
+ $(OLDDOC) merge
240
+ $(INSTALL) -m 644 COPYING doc/COPYING
241
+ $(INSTALL) -m 644 NEWS.atom.xml doc/NEWS.atom.xml
242
+ $(INSTALL) -m 644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
243
+ $(INSTALL) -m 644 $(man1_paths) doc/
244
+ tar cf - $$(git ls-files examples/) | (cd doc && tar xf -)
245
+
246
+ # publishes docs to https://yhbt.net/unicorn/
247
+ publish_doc:
248
+ -git set-file-times
249
+ $(MAKE) doc
250
+ $(MAKE) doc_gz
251
+ chmod 644 $$(find doc -type f)
252
+ $(RSYNC) -av doc/ yhbt.net:/srv/yhbt/unicorn/ \
253
+ --exclude index.html* --exclude created.rid*
254
+ git ls-files | xargs touch
255
+
256
+ # Create gzip variants of the same timestamp as the original so nginx
257
+ # "gzip_static on" can serve the gzipped versions directly.
258
+ doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
259
+ doc_gz:
260
+ for i in $(docs); do \
261
+ gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
262
+
263
+ ifneq ($(VERSION),)
264
+ rfpackage := unicorn-maintained
265
+ pkggem := pkg/$(rfpackage)-$(VERSION).gem
266
+ pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
267
+
268
+ # ensures we're actually on the tagged $(VERSION), only used for release
269
+ verify:
270
+ test x"$(shell umask)" = x0022
271
+ git rev-parse --verify refs/tags/v$(VERSION)^{}
272
+ git diff-index --quiet HEAD^0
273
+ test `git rev-parse --verify HEAD^0` = \
274
+ `git rev-parse --verify refs/tags/v$(VERSION)^{}`
275
+
276
+ fix-perms:
277
+ git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
278
+ git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
279
+
280
+ gem: $(pkggem)
281
+
282
+ install-gem: $(pkggem)
283
+ gem install --local $(CURDIR)/$<
284
+
285
+ $(pkggem): .manifest fix-perms | pkg
286
+ gem build $(rfpackage).gemspec
287
+ mv $(@F) $@
288
+
289
+ $(pkgtgz): distdir = $(basename $@)
290
+ $(pkgtgz): HEAD = v$(VERSION)
291
+ $(pkgtgz): .manifest fix-perms
292
+ @test -n "$(distdir)"
293
+ $(RM) -r $(distdir)
294
+ mkdir -p $(distdir)
295
+ tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
296
+ cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
297
+ mv $@+ $@
298
+
299
+ package: $(pkgtgz) $(pkggem)
300
+
301
+ release: verify package
302
+ # push gem to Gemcutter
303
+ gem push $(pkggem)
304
+ else
305
+ gem install-gem: GIT-VERSION-FILE
306
+ $(MAKE) $@ VERSION=$(GIT_VERSION)
307
+ endif
308
+
309
+ $(PLACEHOLDERS):
310
+ echo olddoc_placeholder > $@
311
+
312
+ check-warnings:
313
+ @(for i in $$(git ls-files '*.rb' bin | grep -v '^setup\.rb$$'); \
314
+ do $(RUBY) --disable-gems -d -W2 -c \
315
+ $$i; done) | grep -v '^Syntax OK$$' || :
316
+
317
+ .PHONY: .FORCE-GIT-VERSION-FILE doc $(T) $(slow_tests) man $(T_sh) clean
data/HACKING ADDED
@@ -0,0 +1,112 @@
1
+ = Unicorn Hacker's Guide
2
+
3
+ == Polyglot Infrastructure
4
+
5
+ Like Mongrel, we use Ruby where it makes sense, and Ragel with C where
6
+ it helps performance. All of the code that actually runs your Rack
7
+ application is written Ruby, Ragel or C.
8
+
9
+ As far as tests and documentation goes, we're not afraid to embrace Unix
10
+ and use traditional Unix tools where they make sense and get the job
11
+ done.
12
+
13
+ === Tests
14
+
15
+ Tests are good, but slow tests make development slow, so we make tests
16
+ faster (in parallel) with GNU make (instead of Rake) and avoiding
17
+ RubyGems.
18
+
19
+ Users of GNU-based systems (such as GNU/Linux) usually have GNU make
20
+ installed as "make" instead of "gmake".
21
+
22
+ Running the entire test suite with 4 tests in parallel:
23
+
24
+ gmake -j4 check
25
+
26
+ Running just one unit test:
27
+
28
+ gmake test/unit/test_http_parser.rb
29
+
30
+ Running just one test case in a unit test:
31
+
32
+ gmake test/unit/test_http_parser.rb--test_parse_simple.n
33
+
34
+ === HttpServer
35
+
36
+ We strive to write as little code as possible while still maintaining
37
+ readability. However, readability and flexibility may be sacrificed for
38
+ performance in hot code paths. For Ruby, less code generally means
39
+ faster code.
40
+
41
+ Memory allocation should be minimized as much as practically possible.
42
+ Buffers for IO#readpartial are preallocated in the hot paths to avoid
43
+ building up garbage. Hash assignments use frozen strings to avoid the
44
+ duplication behind-the-scenes.
45
+
46
+ We spend as little time as possible inside signal handlers and instead
47
+ defer handling them for predictability and robustness. Most of the
48
+ Unix-specific things are in the Unicorn::HttpServer class. Unix systems
49
+ programming experience will come in handy (or be learned) here.
50
+
51
+ === Documentation
52
+
53
+ Please wrap documentation at 72 characters-per-line or less (long URLs
54
+ are exempt) so it is comfortably readable from terminals.
55
+
56
+ When referencing mailing list posts, use
57
+ <tt>https://yhbt.net/unicorn-public/$MESSAGE_ID/</tt> if possible
58
+ since the Message-ID remains searchable even if a particular site
59
+ becomes unavailable.
60
+
61
+ === Ruby/C Compatibility
62
+
63
+ We target C Ruby 2.5 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.
66
+
67
+ All of our C code is OS-independent and should run on compilers
68
+ supported by the versions of Ruby we target.
69
+
70
+ === Ragel Compatibility
71
+
72
+ We target the latest released version of Ragel and will update our code
73
+ to keep up with new releases. Packaged tarballs and gems include the
74
+ generated source code so they will remain usable if compatibility is
75
+ broken.
76
+
77
+ == Contributing
78
+
79
+ Contributions are welcome in the form of patches, pull requests, code
80
+ review, testing, documentation, user support or any other feedback is
81
+ welcome. The mailing list is the central coordination point for all
82
+ user and developer feedback and bug reports.
83
+
84
+ === Submitting Patches
85
+
86
+ Follow conventions already established in the code and do not exceed 80
87
+ characters per line.
88
+
89
+ Inline patches (from "git format-patch -M") to the mailing list are
90
+ preferred because they allow code review and comments in the reply to
91
+ the patch.
92
+
93
+ We will adhere to mostly the same conventions for patch submissions as
94
+ git itself. See the
95
+ {SubmittingPatches}[https://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches]
96
+ document
97
+ distributed with git on on patch submission guidelines to follow. Just
98
+ don't email the git mailing list or maintainer with Unicorn patches :)
99
+
100
+ == Building a Gem
101
+
102
+ You can build the Unicorn gem with the following command:
103
+
104
+ gmake gem
105
+
106
+ == Running Development Versions
107
+
108
+ It is easy to install the contents of your git working directory:
109
+
110
+ Via RubyGems
111
+
112
+ gmake install-gem
data/ISSUES ADDED
@@ -0,0 +1,102 @@
1
+ = Issues
2
+
3
+ mailto:unicorn-public@yhbt.net is the best place to report bugs,
4
+ submit patches and/or obtain support after you have searched the
5
+ {email archives}[https://yhbt.net/unicorn-public/] and
6
+ {documentation}[https://yhbt.net/unicorn/].
7
+
8
+ * No subscription will ever be required to email us
9
+ * Cc: all participants in a thread or commit, as subscription is optional
10
+ * Do not {top post}[http://catb.org/jargon/html/T/top-post.html] in replies
11
+ * Quote as little as possible of the message you're replying to
12
+ * Do not send HTML mail or images,
13
+ they hurt reader privacy and will be flagged as spam
14
+ * Anonymous and pseudonymous messages will ALWAYS be welcome
15
+ * The email submission port (587) is enabled on the yhbt.net MX:
16
+ https://yhbt.net/unicorn-public/20141004232241.GA23908@dcvr.yhbt.net/t/
17
+
18
+ We will never have a centralized or formal bug tracker. Instead we
19
+ can interoperate with any bug tracker which can Cc: us plain-text to
20
+ mailto:unicorn-public@yhbt.net This includes the Debian BTS
21
+ at https://bugs.debian.org/unicorn and possibly others.
22
+
23
+ unicorn is a server; it does not depend on graphics/audio. Nobody
24
+ communicating with us will ever be expected to go through the trouble
25
+ of setting up graphics nor audio support.
26
+
27
+ If your issue is of a sensitive nature or you're just shy in public,
28
+ use anonymity tools such as Tor or Mixmaster; and rely on the public
29
+ mail archives for responses. Be sure to scrub sensitive log messages
30
+ and such.
31
+
32
+ If you don't get a response within a few days, we may have forgotten
33
+ about it so feel free to ask again.
34
+
35
+ The project does not and will never endorse nor promote commercial
36
+ services (including support). The author of unicorn must never be
37
+ allowed to profit off the damage it's done to the entire Ruby world.
38
+
39
+ == Bugs in related projects
40
+
41
+ unicorn is sometimes affected by bugs in its dependencies. Bugs
42
+ triggered by unicorn in mainline Ruby, rack, GNU C library (glibc),
43
+ or the Linux kernel will be reported upstream and fixed.
44
+
45
+ For bugs in Ruby itself, we may forward bugs to
46
+ https://bugs.ruby-lang.org/ and discuss+fix them on the ruby-core
47
+ list at mailto:ruby-core@ruby-lang.org
48
+ Subscription to post is required to ruby-core, unfortunately:
49
+ mailto:ruby-core-request@ruby-lang.org?subject=subscribe
50
+ Unofficial archives are available at: https://public-inbox.org/ruby-core/
51
+
52
+ For uncommon bugs in Rack, we may forward bugs to
53
+ mailto:rack-devel@googlegroups.com and discuss there.
54
+ Subscription (without any web UI or Google account) is possible via:
55
+ mailto:rack-devel+subscribe@googlegroups.com
56
+ Note: not everyone can use the proprietary bug tracker used by Rack,
57
+ but their mailing list remains operational.
58
+ Unofficial archives are available at: https://public-inbox.org/rack-devel/
59
+
60
+ Uncommon bugs we encounter in the Linux kernel should be Cc:-ed to the
61
+ Linux kernel mailing list (LKML) at mailto:linux-kernel@vger.kernel.org
62
+ and subsystem maintainers such as mailto:netdev@vger.kernel.org
63
+ (for networking issues). It is expected practice to Cc: anybody
64
+ involved with any problematic commits (including those in the
65
+ Signed-off-by: and other trailer lines). No subscription is necessary,
66
+ and the our mailing list follows the same conventions as LKML for
67
+ interopability. Archives are available at https://lore.kernel.org/lkml/
68
+ There is a kernel.org Bugzilla instance, but it is ignored by most.
69
+
70
+ Likewise for any rare glibc bugs we might encounter, we should Cc:
71
+ mailto:libc-alpha@sourceware.org
72
+ Archives are available at: https://inbox.sourceware.org/libc-alpha/
73
+ Keep in mind glibc upstream does use Bugzilla for tracking bugs:
74
+ https://sourceware.org/bugzilla/
75
+
76
+ == Submitting Patches
77
+
78
+ See the HACKING document (and additionally, the
79
+ {SubmittingPatches}[https://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches]
80
+ document distributed with git) on guidelines for patch submission.
81
+
82
+ == Contact Info
83
+
84
+ Mail is publicly-archived, SMTP subscription is discouraged to avoid
85
+ servers being a single-point-of-failure, so Cc: all participants.
86
+
87
+ The HTTP(S) archives have links to per-thread Atom feeds and downloadable
88
+ mboxes. Read-only IMAP(S) folders, POP3, and NNTP(S) newsgroups are available.
89
+
90
+ * https://yhbt.net/unicorn-public/
91
+ * http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/unicorn-public/
92
+ * imaps://;AUTH=ANONYMOUS@yhbt.net/inbox.comp.lang.ruby.unicorn.0
93
+ * imap://;AUTH=ANONYMOUS@7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.unicorn.0
94
+ * nntps://news.public-inbox.org/inbox.comp.lang.ruby.unicorn
95
+ * nntp://news.gmane.io/gmane.comp.lang.ruby.unicorn.general
96
+ * https://yhbt.net/unicorn-public/_/text/help/#pop3
97
+
98
+ Full Atom feeds:
99
+ * https://yhbt.net/unicorn-public/new.atom
100
+ * http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/unicorn-public/new.atom
101
+
102
+ We only accept plain-text mail: mailto:unicorn-public@yhbt.net
data/KNOWN_ISSUES ADDED
@@ -0,0 +1,79 @@
1
+ = Known Issues
2
+
3
+ Occasionally odd {issues}[link:ISSUES.html] arise without a transparent or
4
+ acceptable solution. Those issues are documented here.
5
+
6
+ * Some libraries/applications may install signal handlers which conflict
7
+ with signal handlers unicorn uses. Leaving "preload_app false"
8
+ (the default) will allow unicorn to always override existing signal
9
+ handlers.
10
+
11
+ * Issues with FreeBSD jails can be worked around as documented by Tatsuya Ono:
12
+ https://yhbt.net/unicorn-public/CAHBuKRj09FdxAgzsefJWotexw-7JYZGJMtgUp_dhjPz9VbKD6Q@mail.gmail.com/
13
+
14
+ * PRNGs (pseudo-random number generators) loaded before forking
15
+ (e.g. "preload_app true") may need to have their internal state
16
+ reset in the after_fork hook. Starting with unicorn 3.6.1, we
17
+ have builtin workarounds for Kernel#rand and OpenSSL::Random users,
18
+ but applications may use other PRNGs.
19
+
20
+ * For notes on sandboxing tools such as Bundler or Isolate,
21
+ see the {Sandbox}[link:Sandbox.html] page.
22
+
23
+ * nginx with "sendfile on" under FreeBSD 8 is broken when
24
+ uploads are buffered to disk. Disabling sendfile is required to
25
+ work around this bug which should be fixed in newer versions of FreeBSD.
26
+
27
+ * When using "preload_app true", with apps using background threads
28
+ need to restart them in the after_fork hook because threads are never
29
+ shared with child processes. Additionally, any synchronization
30
+ primitives (Mutexes, Monitors, ConditionVariables) should be
31
+ reinitialized in case they are held during fork time to avoid
32
+ deadlocks. The core Ruby Logger class needlessly uses a MonitorMutex
33
+ which can be disabled with a {monkey patch}[link:examples/logger_mp_safe.rb]
34
+
35
+ == Known Issues (Old)
36
+
37
+ * Under some versions of Ruby 1.8, it is necessary to call +srand+ in an
38
+ after_fork hook to get correct random number generation. We have a builtin
39
+ workaround for this starting with unicorn 3.6.1
40
+
41
+ See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/36450
42
+
43
+ * On Ruby 1.8 prior to Ruby 1.8.7-p248, *BSD platforms have a broken
44
+ stdio that causes failure for file uploads larger than 112K. Upgrade
45
+ your version of Ruby or continue using unicorn 1.x/3.4.x.
46
+
47
+ * Under Ruby 1.9.1, methods like Array#shuffle and Array#sample will
48
+ segfault if called after forking. Upgrade to Ruby 1.9.2 or call
49
+ "Kernel.rand" in your after_fork hook to reinitialize the random
50
+ number generator.
51
+
52
+ See http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/28655
53
+
54
+ * Rails 2.3.2 bundles its own version of Rack. This may cause subtle
55
+ bugs when simultaneously loaded with the system-wide Rack Rubygem
56
+ which unicorn depends on. Upgrading to Rails 2.3.4 (or later) is
57
+ strongly recommended for all Rails 2.3.x users for this (and security
58
+ reasons). Rails 2.2.x series (or before) did not bundle Rack and are
59
+ should be unnaffected. If there is any reason which forces your
60
+ application to use Rails 2.3.2 and you have no other choice, then
61
+ you may edit your unicorn gemspec and remove the Rack dependency.
62
+
63
+ ref: https://yhbt.net/unicorn-public/20091014221552.GA30624@dcvr.yhbt.net/
64
+ Note: the workaround described in the article above only made
65
+ the issue more subtle and we didn't notice them immediately.
66
+
67
+ * WONTFIX: code reloading and restarts with Sinatra 0.3.x (and likely older
68
+ versions) apps is broken. The workaround is to force production
69
+ mode to disable code reloading as well as disabling "run" in your
70
+ Sinatra application:
71
+ set :env, :production
72
+ set :run, false
73
+ Since this is no longer an issue with Sinatra 0.9.x apps, this will not be
74
+ fixed on our end. Since unicorn is itself the application launcher, the
75
+ at_exit handler used in old Sinatra always caused Mongrel to be launched
76
+ whenever a unicorn worker was about to exit.
77
+
78
+ Also remember we're capable of replacing the running binary without dropping
79
+ any connections regardless of framework :)
data/LATEST ADDED
@@ -0,0 +1 @@
1
+ Currently unreleased
data/LICENSE ADDED
@@ -0,0 +1,67 @@
1
+ Unicorn is copyrighted free software by all contributors, see logs in
2
+ revision control for names and email addresses of all of them.
3
+
4
+ You can redistribute it and/or modify it under either the terms of the
5
+ GNU General Public License (GPL) as published by the Free Software
6
+ Foundation (FSF), either version 2 of the License, or (at your option)
7
+ any later version. We currently prefer the GPLv3 or later for
8
+ derivative works, but the GPLv2 is fine.
9
+
10
+ The complete texts of the GPLv2 and GPLv3 are below:
11
+ GPLv2 - https://www.gnu.org/licenses/gpl-2.0.txt
12
+ GPLv3 - https://www.gnu.org/licenses/gpl-3.0.txt
13
+
14
+ You may (against our _preference_) also use the Ruby 1.8 license terms
15
+ which we inherited from the original Mongrel project when we forked it:
16
+
17
+ === Ruby 1.8-specific terms (if you're not using the GPL)
18
+
19
+ 1. You may make and give away verbatim copies of the source form of the
20
+ software without restriction, provided that you duplicate all of the
21
+ original copyright notices and associated disclaimers.
22
+
23
+ 2. You may modify your copy of the software in any way, provided that
24
+ you do at least ONE of the following:
25
+
26
+ a) place your modifications in the Public Domain or otherwise make them
27
+ Freely Available, such as by posting said modifications to Usenet or an
28
+ equivalent medium, or by allowing the author to include your
29
+ modifications in the software.
30
+
31
+ b) use the modified software only within your corporation or
32
+ organization.
33
+
34
+ c) rename any non-standard executables so the names do not conflict with
35
+ standard executables, which must also be provided.
36
+
37
+ d) make other distribution arrangements with the author.
38
+
39
+ 3. You may distribute the software in object code or executable
40
+ form, provided that you do at least ONE of the following:
41
+
42
+ a) distribute the executables and library files of the software,
43
+ together with instructions (in the manual page or equivalent) on where
44
+ to get the original distribution.
45
+
46
+ b) accompany the distribution with the machine-readable source of the
47
+ software.
48
+
49
+ c) give non-standard executables non-standard names, with
50
+ instructions on where to get the original software distribution.
51
+
52
+ d) make other distribution arrangements with the author.
53
+
54
+ 4. You may modify and include the part of the software into any other
55
+ software (possibly commercial). But some files in the distribution
56
+ are not written by the author, so that they are not under this terms.
57
+
58
+ 5. The scripts and library files supplied as input to or produced as
59
+ output from the software do not automatically fall under the
60
+ copyright of the software, but belong to whomever generated them,
61
+ and may be sold commercially, and may be aggregated with this
62
+ software.
63
+
64
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
65
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
66
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
67
+ PURPOSE.