unicorn-rupcio 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 (145) 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 +144 -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 +318 -0
  20. data/HACKING +117 -0
  21. data/ISSUES +102 -0
  22. data/KNOWN_ISSUES +79 -0
  23. data/LICENSE +67 -0
  24. data/Links +58 -0
  25. data/PHILOSOPHY +139 -0
  26. data/README +165 -0
  27. data/Rakefile +17 -0
  28. data/SIGNALS +123 -0
  29. data/Sandbox +104 -0
  30. data/TODO +1 -0
  31. data/TUNING +119 -0
  32. data/archive/.gitignore +3 -0
  33. data/archive/slrnpull.conf +4 -0
  34. data/bin/unicorn +129 -0
  35. data/bin/unicorn_rails +210 -0
  36. data/examples/big_app_gc.rb +3 -0
  37. data/examples/echo.ru +27 -0
  38. data/examples/init.sh +102 -0
  39. data/examples/logger_mp_safe.rb +26 -0
  40. data/examples/logrotate.conf +44 -0
  41. data/examples/nginx.conf +156 -0
  42. data/examples/unicorn.conf.minimal.rb +14 -0
  43. data/examples/unicorn.conf.rb +111 -0
  44. data/examples/unicorn.socket +11 -0
  45. data/examples/unicorn@.service +40 -0
  46. data/ext/unicorn_http/CFLAGS +13 -0
  47. data/ext/unicorn_http/c_util.h +115 -0
  48. data/ext/unicorn_http/common_field_optimization.h +128 -0
  49. data/ext/unicorn_http/epollexclusive.h +128 -0
  50. data/ext/unicorn_http/ext_help.h +38 -0
  51. data/ext/unicorn_http/extconf.rb +40 -0
  52. data/ext/unicorn_http/global_variables.h +97 -0
  53. data/ext/unicorn_http/httpdate.c +91 -0
  54. data/ext/unicorn_http/unicorn_http.c +4348 -0
  55. data/ext/unicorn_http/unicorn_http.rl +1054 -0
  56. data/ext/unicorn_http/unicorn_http_common.rl +76 -0
  57. data/lib/unicorn/app/old_rails/static.rb +60 -0
  58. data/lib/unicorn/app/old_rails.rb +36 -0
  59. data/lib/unicorn/cgi_wrapper.rb +148 -0
  60. data/lib/unicorn/configurator.rb +749 -0
  61. data/lib/unicorn/const.rb +22 -0
  62. data/lib/unicorn/http_request.rb +180 -0
  63. data/lib/unicorn/http_response.rb +95 -0
  64. data/lib/unicorn/http_server.rb +860 -0
  65. data/lib/unicorn/launcher.rb +63 -0
  66. data/lib/unicorn/oob_gc.rb +82 -0
  67. data/lib/unicorn/preread_input.rb +34 -0
  68. data/lib/unicorn/select_waiter.rb +7 -0
  69. data/lib/unicorn/socket_helper.rb +186 -0
  70. data/lib/unicorn/stream_input.rb +152 -0
  71. data/lib/unicorn/tee_input.rb +132 -0
  72. data/lib/unicorn/tmpio.rb +34 -0
  73. data/lib/unicorn/util.rb +91 -0
  74. data/lib/unicorn/version.rb +1 -0
  75. data/lib/unicorn/worker.rb +166 -0
  76. data/lib/unicorn.rb +137 -0
  77. data/man/man1/unicorn.1 +222 -0
  78. data/man/man1/unicorn_rails.1 +207 -0
  79. data/setup.rb +1587 -0
  80. data/t/.gitignore +4 -0
  81. data/t/GNUmakefile +5 -0
  82. data/t/README +49 -0
  83. data/t/active-unix-socket.t +110 -0
  84. data/t/back-out-of-upgrade.t +44 -0
  85. data/t/bin/unused_listen +40 -0
  86. data/t/client_body_buffer_size.ru +15 -0
  87. data/t/client_body_buffer_size.t +79 -0
  88. data/t/detach.ru +12 -0
  89. data/t/env.ru +4 -0
  90. data/t/fails-rack-lint.ru +6 -0
  91. data/t/heartbeat-timeout.ru +13 -0
  92. data/t/heartbeat-timeout.t +60 -0
  93. data/t/integration.ru +129 -0
  94. data/t/integration.t +509 -0
  95. data/t/lib.perl +309 -0
  96. data/t/listener_names.ru +5 -0
  97. data/t/my-tap-lib.sh +201 -0
  98. data/t/oob_gc.ru +18 -0
  99. data/t/oob_gc_path.ru +18 -0
  100. data/t/pid.ru +4 -0
  101. data/t/preread_input.ru +23 -0
  102. data/t/reload-bad-config.t +49 -0
  103. data/t/reopen-logs.ru +14 -0
  104. data/t/reopen-logs.t +36 -0
  105. data/t/t0010-reap-logging.sh +55 -0
  106. data/t/t0012-reload-empty-config.sh +86 -0
  107. data/t/t0013-rewindable-input-false.sh +24 -0
  108. data/t/t0013.ru +13 -0
  109. data/t/t0014-rewindable-input-true.sh +24 -0
  110. data/t/t0014.ru +13 -0
  111. data/t/t0015-configurator-internals.sh +25 -0
  112. data/t/t0020-at_exit-handler.sh +49 -0
  113. data/t/t0021-process_detach.sh +29 -0
  114. data/t/t0022-listener_names-preload_app.sh +32 -0
  115. data/t/t0300-no-default-middleware.sh +20 -0
  116. data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
  117. data/t/t0301.ru +14 -0
  118. data/t/t9001-oob_gc.sh +47 -0
  119. data/t/t9002-oob_gc-path.sh +75 -0
  120. data/t/test-lib.sh +125 -0
  121. data/t/winch_ttin.t +64 -0
  122. data/t/working_directory.t +86 -0
  123. data/test/aggregate.rb +16 -0
  124. data/test/benchmark/README +60 -0
  125. data/test/benchmark/dd.ru +19 -0
  126. data/test/benchmark/ddstream.ru +51 -0
  127. data/test/benchmark/readinput.ru +41 -0
  128. data/test/benchmark/stack.ru +9 -0
  129. data/test/benchmark/uconnect.perl +66 -0
  130. data/test/exec/README +5 -0
  131. data/test/exec/test_exec.rb +1030 -0
  132. data/test/test_helper.rb +307 -0
  133. data/test/unit/test_configurator.rb +176 -0
  134. data/test/unit/test_droplet.rb +29 -0
  135. data/test/unit/test_http_parser.rb +885 -0
  136. data/test/unit/test_http_parser_ng.rb +715 -0
  137. data/test/unit/test_server.rb +245 -0
  138. data/test/unit/test_signals.rb +189 -0
  139. data/test/unit/test_socket_helper.rb +160 -0
  140. data/test/unit/test_stream_input.rb +211 -0
  141. data/test/unit/test_tee_input.rb +304 -0
  142. data/test/unit/test_util.rb +132 -0
  143. data/test/unit/test_waiter.rb +35 -0
  144. data/unicorn.gemspec +49 -0
  145. metadata +266 -0
data/GNUmakefile ADDED
@@ -0,0 +1,318 @@
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
+ build: $(tmp_bins)
82
+
83
+ $(tmp_bin)/%: bin/% | $(tmp_bin)
84
+ $(INSTALL) -m 755 $< $@.$(pid)
85
+ $(MRI) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $@.$(pid)
86
+ mv $@.$(pid) $@
87
+
88
+ bins: $(tmp_bins)
89
+
90
+ t_log := $(T_log) $(T_n_log)
91
+ test: $(T) $(T_n) test-prove
92
+ @cat $(t_log) | $(MRI) test/aggregate.rb
93
+ @$(RM) $(t_log)
94
+
95
+ test-exec: $(wildcard test/exec/test_*.rb)
96
+ test-unit: $(wildcard test/unit/test_*.rb)
97
+ $(slow_tests): $(ext_dl)
98
+ @$(MAKE) $(shell $(awk_slow) $@)
99
+
100
+ # ensure we can require just the HTTP parser without the rest of unicorn
101
+ test-require: $(ext_dl)
102
+ $(RUBY) --disable-gems -I$(ext_pfx)/$(ext) -runicorn_http -e Unicorn
103
+
104
+ test_prereq := $(tmp_bins) $(ext_dl)
105
+
106
+ SH_TEST_OPTS =
107
+ ifdef V
108
+ ifeq ($(V),2)
109
+ SH_TEST_OPTS += --trace
110
+ else
111
+ SH_TEST_OPTS += --verbose
112
+ endif
113
+ endif
114
+
115
+ # do we trust Ruby behavior to be stable? some tests are
116
+ # (mostly) POSIX sh (not bash or ksh93, so no "set -o pipefail"
117
+ # TRACER = strace -f -o $(t_pfx).strace -s 100000
118
+ # TRACER = /usr/bin/time -o $(t_pfx).time
119
+ t_pfx = trash/$@-$(RUBY_ENGINE)-$(RUBY_VERSION)
120
+ T_sh = $(wildcard t/t[0-9][0-9][0-9][0-9]-*.sh)
121
+ $(T_sh): export RUBY := $(RUBY)
122
+ $(T_sh): export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
123
+ $(T_sh): export RUBYLIB := $(lib):$(RUBYLIB)
124
+ $(T_sh): dep $(test_prereq) t/random_blob t/trash/.gitignore
125
+ cd t && $(TRACER) $(SHELL) $(SH_TEST_OPTS) $(@F) $(TEST_OPTS)
126
+
127
+ t/trash/.gitignore : | t/trash
128
+ echo '*' >$@
129
+
130
+ dependencies := curl
131
+ deps := $(addprefix t/.dep+,$(dependencies))
132
+ $(deps): dep_bin = $(lastword $(subst +, ,$@))
133
+ $(deps):
134
+ @which $(dep_bin) > $@.$(pid) 2>/dev/null || :
135
+ @test -s $@.$(pid) || \
136
+ { echo >&2 "E '$(dep_bin)' not found in PATH=$(PATH)"; exit 1; }
137
+ @mv $@.$(pid) $@
138
+ dep: $(deps)
139
+
140
+ t/random_blob:
141
+ dd if=/dev/urandom bs=1M count=30 of=$@.$(pid)
142
+ mv $@.$(pid) $@
143
+
144
+ test-integration: $(T_sh)
145
+
146
+ test-prove: t/random_blob
147
+ $(PROVE) -vw
148
+
149
+ check: test-require test test-integration
150
+ test-all: check
151
+
152
+ TEST_OPTS = -v
153
+ check_test = grep '0 failures, 0 errors' $(t) >/dev/null
154
+ ifndef V
155
+ quiet_pre = @echo '* $(arg)$(extra)';
156
+ quiet_post = >$(t) 2>&1 && $(check_test)
157
+ else
158
+ # we can't rely on -o pipefail outside of bash 3+,
159
+ # so we use a stamp file to indicate success and
160
+ # have rm fail if the stamp didn't get created
161
+ stamp = $@$(log_suffix).ok
162
+ quiet_pre = @echo $(RUBY) $(arg) $(TEST_OPTS); ! test -f $(stamp) && (
163
+ quiet_post = && > $(stamp) )2>&1 | tee $(t); \
164
+ rm $(stamp) 2>/dev/null && $(check_test)
165
+ endif
166
+
167
+ # not all systems have setsid(8), we need it because we spam signals
168
+ # stupidly in some tests...
169
+ rb_setsid := $(RUBY) -e 'Process.setsid' -e 'exec *ARGV'
170
+
171
+ # TRACER='strace -f -o $(t).strace -s 100000'
172
+ run_test = $(quiet_pre) \
173
+ $(rb_setsid) $(TRACER) $(RUBY) -w $(arg) $(TEST_OPTS) $(quiet_post) || \
174
+ (sed "s,^,$(extra): ," >&2 < $(t); exit 1)
175
+
176
+ %.n: arg = $(subst .n,,$(subst --, -n ,$@))
177
+ %.n: t = $(subst .n,$(log_suffix),$@)
178
+ %.n: export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
179
+ %.n: export RUBYLIB := $(lib):$(RUBYLIB)
180
+ %.n: $(test_prereq)
181
+ $(run_test)
182
+
183
+ $(T): arg = $@
184
+ $(T): t = $(subst .rb,$(log_suffix),$@)
185
+ $(T): export PATH := $(CURDIR)/$(tmp_bin):$(PATH)
186
+ $(T): export RUBYLIB := $(lib):$(RUBYLIB)
187
+ $(T): $(test_prereq)
188
+ $(run_test)
189
+
190
+ install: $(bins) $(ext)/unicorn_http.c
191
+ $(prep_setup_rb)
192
+ $(RM) -r .install-tmp
193
+ mkdir .install-tmp
194
+ cp -p bin/* .install-tmp
195
+ $(RUBY) setup.rb all
196
+ $(RM) $^
197
+ mv .install-tmp/* bin/
198
+ $(RM) -r .install-tmp
199
+ $(prep_setup_rb)
200
+
201
+ setup_rb_files := .config InstalledFiles
202
+ prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
203
+
204
+ clean:
205
+ -$(MAKE) -C $(ext) clean
206
+ $(RM) $(ext)/Makefile
207
+ $(RM) $(setup_rb_files) $(t_log)
208
+ $(RM) -r $(ext_pfx) man t/trash
209
+ $(RM) $(html1)
210
+
211
+ man1 := $(addprefix Documentation/, unicorn.1 unicorn_rails.1)
212
+ html1 := $(addsuffix .html, $(man1))
213
+ man : $(man1) | man/man1
214
+ $(INSTALL) -m 644 $(man1) man/man1
215
+
216
+ html : $(html1) | doc/man1
217
+ $(INSTALL) -m 644 $(html1) doc/man1
218
+
219
+ %.1.html: %.1
220
+ $(OLDDOC) man2html -o $@ ./$<
221
+
222
+ pkg_extra := GIT-VERSION-FILE lib/unicorn/version.rb \
223
+ $(ext)/unicorn_http.c $(man1_paths)
224
+
225
+ NEWS:
226
+ # $(OLDDOC) prepare
227
+
228
+ .manifest: $(ext)/unicorn_http.c man NEWS
229
+ (git ls-files && for i in $@ $(pkg_extra); do echo $$i; done) | \
230
+ LC_ALL=C sort > $@+
231
+ cmp $@+ $@ || mv $@+ $@
232
+ $(RM) $@+
233
+
234
+ PLACEHOLDERS = $(man1_rdoc)
235
+ # doc: .document $(ext)/unicorn_http.c man html .olddoc.yml $(PLACEHOLDERS)
236
+ # find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
237
+ # $(RM) -r doc
238
+ # $(OLDDOC) prepare
239
+ # $(RDOC) -f dark216
240
+ # $(OLDDOC) merge
241
+ # $(INSTALL) -m 644 COPYING doc/COPYING
242
+ # $(INSTALL) -m 644 NEWS.atom.xml doc/NEWS.atom.xml
243
+ # $(INSTALL) -m 644 $(shell LC_ALL=C grep '^[A-Z]' .document) doc/
244
+ # $(INSTALL) -m 644 $(man1_paths) doc/
245
+ # tar cf - $$(git ls-files examples/) | (cd doc && tar xf -)
246
+ #
247
+ # # publishes docs to https://yhbt.net/unicorn/
248
+ # publish_doc:
249
+ # -git set-file-times
250
+ # $(MAKE) doc
251
+ # $(MAKE) doc_gz
252
+ # chmod 644 $$(find doc -type f)
253
+ # $(RSYNC) -av doc/ yhbt.net:/srv/yhbt/unicorn/ \
254
+ # --exclude index.html* --exclude created.rid*
255
+ # git ls-files | xargs touch
256
+ #
257
+ # Create gzip variants of the same timestamp as the original so nginx
258
+ # "gzip_static on" can serve the gzipped versions directly.
259
+ doc_gz: docs = $(shell find doc -type f ! -regex '^.*\.gz$$')
260
+ doc_gz:
261
+ for i in $(docs); do \
262
+ gzip --rsyncable -9 < $$i > $$i.gz; touch -r $$i $$i.gz; done
263
+
264
+ ifneq ($(VERSION),)
265
+ rfpackage := unicorn
266
+ pkggem := pkg/$(rfpackage)-$(VERSION).gem
267
+ pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
268
+
269
+ # ensures we're actually on the tagged $(VERSION), only used for release
270
+ verify:
271
+ test x"$(shell umask)" = x0022
272
+ git rev-parse --verify refs/tags/v$(VERSION)^{}
273
+ git diff-index --quiet HEAD^0
274
+ test `git rev-parse --verify HEAD^0` = \
275
+ `git rev-parse --verify refs/tags/v$(VERSION)^{}`
276
+
277
+ fix-perms:
278
+ git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
279
+ git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
280
+
281
+ gem: $(pkggem)
282
+
283
+ install-gem: $(pkggem)
284
+ gem install --local $(CURDIR)/$<
285
+
286
+ $(pkggem): .manifest fix-perms | pkg
287
+ gem build $(rfpackage).gemspec
288
+ mv $(@F) $@
289
+
290
+ $(pkgtgz): distdir = $(basename $@)
291
+ $(pkgtgz): HEAD = v$(VERSION)
292
+ $(pkgtgz): .manifest fix-perms
293
+ @test -n "$(distdir)"
294
+ $(RM) -r $(distdir)
295
+ mkdir -p $(distdir)
296
+ tar cf - $$(cat .manifest) | (cd $(distdir) && tar xf -)
297
+ cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
298
+ mv $@+ $@
299
+
300
+ package: $(pkgtgz) $(pkggem)
301
+
302
+ release: verify package
303
+ # push gem to Gemcutter
304
+ gem push $(pkggem)
305
+ else
306
+ gem install-gem: GIT-VERSION-FILE
307
+ $(MAKE) $@ VERSION=$(GIT_VERSION)
308
+ endif
309
+
310
+ $(PLACEHOLDERS):
311
+ # echo olddoc_placeholder > $@
312
+
313
+ check-warnings:
314
+ @(for i in $$(git ls-files '*.rb' bin | grep -v '^setup\.rb$$'); \
315
+ do $(RUBY) --disable-gems -d -W2 -c \
316
+ $$i; done) | grep -v '^Syntax OK$$' || :
317
+
318
+ .PHONY: .FORCE-GIT-VERSION-FILE doc $(T) $(slow_tests) man $(T_sh) clean
data/HACKING ADDED
@@ -0,0 +1,117 @@
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
+ Ragel may be dropped in favor of a picohttpparser-based one in the future.
10
+
11
+ As far as tests and documentation goes, we're not afraid to embrace Unix
12
+ and use traditional Unix tools where they make sense and get the job
13
+ done.
14
+
15
+ === Tests
16
+
17
+ Tests are good, but slow tests make development slow, so we make tests
18
+ faster (in parallel) with GNU make (instead of Rake) and avoiding
19
+ RubyGems.
20
+
21
+ New tests are written in Perl 5 and use TAP <https://testanything.org/>
22
+ to ensure stability and immunity from Ruby incompatibilities.
23
+
24
+ Users of GNU-based systems (such as GNU/Linux) usually have GNU make
25
+ installed as "make" instead of "gmake".
26
+
27
+ Running the entire test suite with 4 tests in parallel:
28
+
29
+ gmake -j4 check
30
+
31
+ Running just one unit test:
32
+
33
+ gmake test/unit/test_http_parser.rb
34
+
35
+ Running just one test case in a unit test:
36
+
37
+ gmake test/unit/test_http_parser.rb--test_parse_simple.n
38
+
39
+ === HttpServer
40
+
41
+ We strive to write as little code as possible while still maintaining
42
+ readability. However, readability and flexibility may be sacrificed for
43
+ performance in hot code paths. For Ruby, less code generally means
44
+ faster code.
45
+
46
+ Memory allocation should be minimized as much as practically possible.
47
+ Buffers for IO#readpartial are preallocated in the hot paths to avoid
48
+ building up garbage. Hash assignments use frozen strings to avoid the
49
+ duplication behind-the-scenes.
50
+
51
+ We spend as little time as possible inside signal handlers and instead
52
+ defer handling them for predictability and robustness. Most of the
53
+ Unix-specific things are in the Unicorn::HttpServer class. Unix systems
54
+ programming experience will come in handy (or be learned) here.
55
+
56
+ === Documentation
57
+
58
+ Please wrap documentation at 72 characters-per-line or less (long URLs
59
+ are exempt) so it is comfortably readable from terminals.
60
+
61
+ When referencing mailing list posts, use
62
+ <tt>https://yhbt.net/unicorn-public/$MESSAGE_ID/</tt> if possible
63
+ since the Message-ID remains searchable even if a particular site
64
+ becomes unavailable.
65
+
66
+ === Ruby/C Compatibility
67
+
68
+ We target C Ruby 2.5 and later. We need the Ruby
69
+ implementation to support fork, exec, pipe, UNIX signals, access to
70
+ integer file descriptors and ability to use unlinked files.
71
+
72
+ All of our C code is OS-independent and should run on compilers
73
+ supported by the versions of Ruby we target.
74
+
75
+ === Ragel Compatibility
76
+
77
+ We target the latest released version of Ragel in Debian and will update
78
+ our code to keep up with new releases. Packaged tarballs and gems
79
+ include the generated source code so they will remain usable if
80
+ compatibility is broken.
81
+
82
+ == Contributing
83
+
84
+ Contributions are welcome in the form of patches, pull requests, code
85
+ review, testing, documentation, user support or any other feedback is
86
+ welcome. The mailing list is the central coordination point for all
87
+ user and developer feedback and bug reports.
88
+
89
+ === Submitting Patches
90
+
91
+ Follow conventions already established in the code and do not exceed 80
92
+ characters per line.
93
+
94
+ Inline patches (from "git format-patch -M") to the mailing list are
95
+ preferred because they allow code review and comments in the reply to
96
+ the patch.
97
+
98
+ We will adhere to mostly the same conventions for patch submissions as
99
+ git itself. See the
100
+ {SubmittingPatches}[https://git.kernel.org/cgit/git/git.git/tree/Documentation/SubmittingPatches]
101
+ document
102
+ distributed with git on on patch submission guidelines to follow. Just
103
+ don't email the git mailing list or maintainer with Unicorn patches :)
104
+
105
+ == Building a Gem
106
+
107
+ You can build the Unicorn gem with the following command:
108
+
109
+ gmake gem
110
+
111
+ == Running Development Versions
112
+
113
+ It is easy to install the contents of your git working directory:
114
+
115
+ Via RubyGems
116
+
117
+ 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/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.