unicorn-fotopedia 0.99.1

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 (163) hide show
  1. data/.CHANGELOG.old +25 -0
  2. data/.document +19 -0
  3. data/.gitignore +21 -0
  4. data/.mailmap +26 -0
  5. data/CONTRIBUTORS +32 -0
  6. data/COPYING +339 -0
  7. data/DESIGN +105 -0
  8. data/Documentation/.gitignore +5 -0
  9. data/Documentation/GNUmakefile +30 -0
  10. data/Documentation/unicorn.1.txt +171 -0
  11. data/Documentation/unicorn_rails.1.txt +172 -0
  12. data/FAQ +52 -0
  13. data/GIT-VERSION-GEN +40 -0
  14. data/GNUmakefile +292 -0
  15. data/HACKING +116 -0
  16. data/ISSUES +36 -0
  17. data/KNOWN_ISSUES +50 -0
  18. data/LICENSE +55 -0
  19. data/PHILOSOPHY +145 -0
  20. data/README +149 -0
  21. data/Rakefile +191 -0
  22. data/SIGNALS +109 -0
  23. data/Sandbox +78 -0
  24. data/TODO +5 -0
  25. data/TUNING +70 -0
  26. data/bin/unicorn +126 -0
  27. data/bin/unicorn_rails +203 -0
  28. data/examples/big_app_gc.rb +33 -0
  29. data/examples/echo.ru +27 -0
  30. data/examples/git.ru +13 -0
  31. data/examples/init.sh +58 -0
  32. data/examples/logger_mp_safe.rb +25 -0
  33. data/examples/nginx.conf +139 -0
  34. data/examples/unicorn.conf.rb +78 -0
  35. data/ext/unicorn_http/CFLAGS +13 -0
  36. data/ext/unicorn_http/c_util.h +124 -0
  37. data/ext/unicorn_http/common_field_optimization.h +111 -0
  38. data/ext/unicorn_http/ext_help.h +77 -0
  39. data/ext/unicorn_http/extconf.rb +14 -0
  40. data/ext/unicorn_http/global_variables.h +89 -0
  41. data/ext/unicorn_http/unicorn_http.rl +714 -0
  42. data/ext/unicorn_http/unicorn_http_common.rl +75 -0
  43. data/lib/unicorn.rb +847 -0
  44. data/lib/unicorn/app/exec_cgi.rb +150 -0
  45. data/lib/unicorn/app/inetd.rb +109 -0
  46. data/lib/unicorn/app/old_rails.rb +33 -0
  47. data/lib/unicorn/app/old_rails/static.rb +58 -0
  48. data/lib/unicorn/cgi_wrapper.rb +145 -0
  49. data/lib/unicorn/configurator.rb +421 -0
  50. data/lib/unicorn/const.rb +34 -0
  51. data/lib/unicorn/http_request.rb +72 -0
  52. data/lib/unicorn/http_response.rb +75 -0
  53. data/lib/unicorn/launcher.rb +65 -0
  54. data/lib/unicorn/oob_gc.rb +58 -0
  55. data/lib/unicorn/socket_helper.rb +152 -0
  56. data/lib/unicorn/tee_input.rb +217 -0
  57. data/lib/unicorn/util.rb +90 -0
  58. data/local.mk.sample +62 -0
  59. data/setup.rb +1586 -0
  60. data/t/.gitignore +2 -0
  61. data/t/GNUmakefile +67 -0
  62. data/t/README +42 -0
  63. data/t/bin/content-md5-put +36 -0
  64. data/t/bin/sha1sum.rb +23 -0
  65. data/t/bin/unused_listen +40 -0
  66. data/t/bin/utee +12 -0
  67. data/t/env.ru +3 -0
  68. data/t/my-tap-lib.sh +200 -0
  69. data/t/t0000-http-basic.sh +50 -0
  70. data/t/t0001-reload-bad-config.sh +52 -0
  71. data/t/t0002-config-conflict.sh +49 -0
  72. data/t/test-lib.sh +100 -0
  73. data/test/aggregate.rb +15 -0
  74. data/test/benchmark/README +50 -0
  75. data/test/benchmark/dd.ru +18 -0
  76. data/test/exec/README +5 -0
  77. data/test/exec/test_exec.rb +1038 -0
  78. data/test/rails/app-1.2.3/.gitignore +2 -0
  79. data/test/rails/app-1.2.3/Rakefile +7 -0
  80. data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
  81. data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
  82. data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
  83. data/test/rails/app-1.2.3/config/boot.rb +11 -0
  84. data/test/rails/app-1.2.3/config/database.yml +12 -0
  85. data/test/rails/app-1.2.3/config/environment.rb +13 -0
  86. data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
  87. data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
  88. data/test/rails/app-1.2.3/config/routes.rb +6 -0
  89. data/test/rails/app-1.2.3/db/.gitignore +0 -0
  90. data/test/rails/app-1.2.3/public/404.html +1 -0
  91. data/test/rails/app-1.2.3/public/500.html +1 -0
  92. data/test/rails/app-2.0.2/.gitignore +2 -0
  93. data/test/rails/app-2.0.2/Rakefile +7 -0
  94. data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
  95. data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
  96. data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
  97. data/test/rails/app-2.0.2/config/boot.rb +11 -0
  98. data/test/rails/app-2.0.2/config/database.yml +12 -0
  99. data/test/rails/app-2.0.2/config/environment.rb +17 -0
  100. data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
  101. data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
  102. data/test/rails/app-2.0.2/config/routes.rb +6 -0
  103. data/test/rails/app-2.0.2/db/.gitignore +0 -0
  104. data/test/rails/app-2.0.2/public/404.html +1 -0
  105. data/test/rails/app-2.0.2/public/500.html +1 -0
  106. data/test/rails/app-2.1.2/.gitignore +2 -0
  107. data/test/rails/app-2.1.2/Rakefile +7 -0
  108. data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
  109. data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
  110. data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
  111. data/test/rails/app-2.1.2/config/boot.rb +111 -0
  112. data/test/rails/app-2.1.2/config/database.yml +12 -0
  113. data/test/rails/app-2.1.2/config/environment.rb +17 -0
  114. data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
  115. data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
  116. data/test/rails/app-2.1.2/config/routes.rb +6 -0
  117. data/test/rails/app-2.1.2/db/.gitignore +0 -0
  118. data/test/rails/app-2.1.2/public/404.html +1 -0
  119. data/test/rails/app-2.1.2/public/500.html +1 -0
  120. data/test/rails/app-2.2.2/.gitignore +2 -0
  121. data/test/rails/app-2.2.2/Rakefile +7 -0
  122. data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
  123. data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
  124. data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
  125. data/test/rails/app-2.2.2/config/boot.rb +111 -0
  126. data/test/rails/app-2.2.2/config/database.yml +12 -0
  127. data/test/rails/app-2.2.2/config/environment.rb +17 -0
  128. data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
  129. data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
  130. data/test/rails/app-2.2.2/config/routes.rb +6 -0
  131. data/test/rails/app-2.2.2/db/.gitignore +0 -0
  132. data/test/rails/app-2.2.2/public/404.html +1 -0
  133. data/test/rails/app-2.2.2/public/500.html +1 -0
  134. data/test/rails/app-2.3.5/.gitignore +2 -0
  135. data/test/rails/app-2.3.5/Rakefile +7 -0
  136. data/test/rails/app-2.3.5/app/controllers/application_controller.rb +5 -0
  137. data/test/rails/app-2.3.5/app/controllers/foo_controller.rb +36 -0
  138. data/test/rails/app-2.3.5/app/helpers/application_helper.rb +4 -0
  139. data/test/rails/app-2.3.5/config/boot.rb +109 -0
  140. data/test/rails/app-2.3.5/config/database.yml +12 -0
  141. data/test/rails/app-2.3.5/config/environment.rb +17 -0
  142. data/test/rails/app-2.3.5/config/environments/development.rb +7 -0
  143. data/test/rails/app-2.3.5/config/environments/production.rb +6 -0
  144. data/test/rails/app-2.3.5/config/routes.rb +6 -0
  145. data/test/rails/app-2.3.5/db/.gitignore +0 -0
  146. data/test/rails/app-2.3.5/public/404.html +1 -0
  147. data/test/rails/app-2.3.5/public/500.html +1 -0
  148. data/test/rails/app-2.3.5/public/x.txt +1 -0
  149. data/test/rails/test_rails.rb +280 -0
  150. data/test/test_helper.rb +301 -0
  151. data/test/unit/test_configurator.rb +150 -0
  152. data/test/unit/test_http_parser.rb +555 -0
  153. data/test/unit/test_http_parser_ng.rb +443 -0
  154. data/test/unit/test_request.rb +184 -0
  155. data/test/unit/test_response.rb +110 -0
  156. data/test/unit/test_server.rb +291 -0
  157. data/test/unit/test_signals.rb +206 -0
  158. data/test/unit/test_socket_helper.rb +147 -0
  159. data/test/unit/test_tee_input.rb +257 -0
  160. data/test/unit/test_upload.rb +298 -0
  161. data/test/unit/test_util.rb +96 -0
  162. data/unicorn.gemspec +52 -0
  163. metadata +283 -0
data/FAQ ADDED
@@ -0,0 +1,52 @@
1
+ = Frequently Asked Questions about Unicorn
2
+
3
+ === I've installed Rack 1.1.x, why can't Unicorn load Rails?
4
+
5
+ Rails 2.3.5 is not compatible with Rack 1.1.x. Unicorn is compatible
6
+ with both Rack 1.1.x and Rack 1.0.x, and RubyGems will load the latest
7
+ version of Rack installed on the system. Uninstalling the Rack 1.1.x
8
+ gem should solve gem loading issues with Rails 2.3.x.
9
+
10
+ === Why are my redirects going to "http" URLs when my site uses https?
11
+
12
+ If your site is entirely behind https, then Rack applications that use
13
+ "rack.url_scheme" can set the following in the Unicorn config file:
14
+
15
+ HttpRequest::DEFAULTS["rack.url_scheme"] = "https"
16
+
17
+ For frameworks that do not use "rack.url_scheme", you can also
18
+ try setting one or both of the following:
19
+
20
+ HttpRequest::DEFAULTS["HTTPS"] = "on"
21
+ HttpRequest::DEFAULTS["HTTP_X_FORWARDED_PROTO"] = "https"
22
+
23
+ Otherwise, you can configure your proxy (nginx) to send the
24
+ "X-Forwarded-Proto: https" header only for parts of the site that use
25
+ https. For nginx, you can do it with the following line in appropriate
26
+ "location" blocks of your nginx config file:
27
+
28
+ proxy_set_header X-Forwarded-Proto https;
29
+
30
+ === Why are log messages from Unicorn are unformatted when using Rails?
31
+
32
+ Current versions of Rails unfortunately overrides the default Logger
33
+ formatter.
34
+
35
+ You can undo this behavior with the default logger in your Unicorn
36
+ config file:
37
+
38
+ Configurator::DEFAULTS[:logger].formatter = Logger::Formatter.new
39
+
40
+ Of course you can specify an entirely different logger as well
41
+ with the "logger" directive described by Unicorn::Configurator.
42
+
43
+ === Why am I getting "connection refused"/502 errors under high load?
44
+
45
+ Short answer: your application cannot keep up.
46
+
47
+ You can increase the size of the :backlog parameter if your kernel
48
+ supports a larger listen() queue, but keep in mind having a large listen
49
+ queue makes failover to a different machine more difficult.
50
+
51
+ See the TUNING and Unicorn::Configurator documents for more information
52
+ on :backlog-related topics.
@@ -0,0 +1,40 @@
1
+ #!/bin/sh
2
+
3
+ GVF=GIT-VERSION-FILE
4
+ DEF_VER=v0.99.0.GIT
5
+
6
+ LF='
7
+ '
8
+
9
+ # First see if there is a version file (included in release tarballs),
10
+ # then try git-describe, then default.
11
+ if test -f version
12
+ then
13
+ VN=$(cat version) || VN="$DEF_VER"
14
+ elif test -d .git -o -f .git &&
15
+ VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
16
+ case "$VN" in
17
+ *$LF*) (exit 1) ;;
18
+ v[0-9]*)
19
+ git update-index -q --refresh
20
+ test -z "$(git diff-index --name-only HEAD --)" ||
21
+ VN="$VN-dirty" ;;
22
+ esac
23
+ then
24
+ VN=$(echo "$VN" | sed -e 's/-/./g');
25
+ else
26
+ VN="$DEF_VER"
27
+ fi
28
+
29
+ VN=$(expr "$VN" : v*'\(.*\)')
30
+
31
+ if test -r $GVF
32
+ then
33
+ VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
34
+ else
35
+ VC=unset
36
+ fi
37
+ test "$VN" = "$VC" || {
38
+ echo >&2 "GIT_VERSION = $VN"
39
+ echo "GIT_VERSION = $VN" >$GVF
40
+ }
@@ -0,0 +1,292 @@
1
+ # use GNU Make to run tests in parallel, and without depending on RubyGems
2
+ all:: test
3
+
4
+ GIT_URL = git://git.bogomips.org/unicorn.git
5
+ RLFLAGS = -G2
6
+
7
+ # lower-case vars are deprecated
8
+ RUBY = ruby
9
+ RAKE = rake
10
+ RAGEL = ragel
11
+
12
+ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
13
+ @./GIT-VERSION-GEN
14
+ -include GIT-VERSION-FILE
15
+ -include local.mk
16
+ ruby_bin := $(shell which $(RUBY))
17
+ ifeq ($(DLEXT),) # "so" for Linux
18
+ DLEXT := $(shell $(RUBY) -rrbconfig -e 'puts Config::CONFIG["DLEXT"]')
19
+ endif
20
+ ifeq ($(RUBY_VERSION),)
21
+ RUBY_VERSION := $(shell $(RUBY) -e 'puts RUBY_VERSION')
22
+ endif
23
+
24
+ # dunno how to implement this as concisely in Ruby, and hell, I love awk
25
+ awk_slow := awk '/def test_/{print FILENAME"--"$$2".n"}' 2>/dev/null
26
+
27
+ rails_vers := $(subst test/rails/app-,,$(wildcard test/rails/app-*))
28
+ slow_tests := test/unit/test_server.rb test/exec/test_exec.rb \
29
+ test/unit/test_signals.rb test/unit/test_upload.rb
30
+ log_suffix = .$(RUBY_VERSION).log
31
+ T_r := $(wildcard test/rails/test*.rb)
32
+ T := $(filter-out $(slow_tests) $(T_r), $(wildcard test/*/test*.rb))
33
+ T_n := $(shell $(awk_slow) $(slow_tests))
34
+ T_log := $(subst .rb,$(log_suffix),$(T))
35
+ T_n_log := $(subst .n,$(log_suffix),$(T_n))
36
+ T_r_log := $(subst .r,$(log_suffix),$(T_r))
37
+ test_prefix = $(CURDIR)/test/install-$(RUBY_VERSION)
38
+
39
+ ext := ext/unicorn_http
40
+ c_files := $(ext)/unicorn_http.c $(wildcard $(ext)/*.h)
41
+ rl_files := $(wildcard $(ext)/*.rl)
42
+ base_bins := unicorn unicorn_rails
43
+ bins := $(addprefix bin/, $(base_bins))
44
+ man1_rdoc := $(addsuffix _1, $(base_bins))
45
+ man1_bins := $(addsuffix .1, $(base_bins))
46
+ man1_paths := $(addprefix man/man1/, $(man1_bins))
47
+ rb_files := $(bins) $(shell find lib ext -type f -name '*.rb')
48
+ inst_deps := $(c_files) $(rb_files) GNUmakefile test/test_helper.rb
49
+
50
+ ragel: $(ext)/unicorn_http.c
51
+ $(ext)/unicorn_http.c: $(rl_files)
52
+ cd $(@D) && $(RAGEL) unicorn_http.rl -C $(RLFLAGS) -o $(@F)
53
+ $(ext)/Makefile: $(ext)/extconf.rb $(c_files)
54
+ cd $(@D) && $(RUBY) extconf.rb
55
+ $(ext)/unicorn_http.$(DLEXT): $(ext)/Makefile
56
+ $(MAKE) -C $(@D)
57
+ lib/unicorn_http.$(DLEXT): $(ext)/unicorn_http.$(DLEXT)
58
+ @mkdir -p lib
59
+ install -m644 $< $@
60
+ http: lib/unicorn_http.$(DLEXT)
61
+
62
+ test-install: $(test_prefix)/.stamp
63
+ $(test_prefix)/.stamp: $(inst_deps)
64
+ mkdir -p $(test_prefix)/.ccache
65
+ tar cf - $(inst_deps) GIT-VERSION-GEN | \
66
+ (cd $(test_prefix) && tar xf -)
67
+ $(MAKE) -C $(test_prefix) clean
68
+ $(MAKE) -C $(test_prefix) http shebang
69
+ > $@
70
+
71
+ # this is only intended to be run within $(test_prefix)
72
+ shebang: $(bins)
73
+ $(RUBY) -i -p -e '$$_.gsub!(%r{^#!.*$$},"#!$(ruby_bin)")' $^
74
+
75
+ t_log := $(T_log) $(T_n_log)
76
+ test: $(T) $(T_n)
77
+ @cat $(t_log) | $(RUBY) test/aggregate.rb
78
+ @$(RM) $(t_log)
79
+
80
+ test-exec: $(wildcard test/exec/test_*.rb)
81
+ test-unit: $(wildcard test/unit/test_*.rb)
82
+ $(slow_tests): $(test_prefix)/.stamp
83
+ @$(MAKE) $(shell $(awk_slow) $@)
84
+
85
+ TEST_OPTS = -v
86
+ check_test = grep '0 failures, 0 errors' $(t) >/dev/null
87
+ ifndef V
88
+ quiet_pre = @echo '* $(arg)$(extra)';
89
+ quiet_post = >$(t) 2>&1 && $(check_test)
90
+ else
91
+ # we can't rely on -o pipefail outside of bash 3+,
92
+ # so we use a stamp file to indicate success and
93
+ # have rm fail if the stamp didn't get created
94
+ stamp = $@$(log_suffix).ok
95
+ quiet_pre = @echo $(RUBY) $(arg) $(TEST_OPTS); ! test -f $(stamp) && (
96
+ quiet_post = && > $(stamp) )2>&1 | tee $(t); \
97
+ rm $(stamp) 2>/dev/null && $(check_test)
98
+ endif
99
+
100
+ # not all systems have setsid(8), we need it because we spam signals
101
+ # stupidly in some tests...
102
+ rb_setsid := $(RUBY) -e 'Process.setsid' -e 'exec *ARGV'
103
+
104
+ # TRACER='strace -f -o $(t).strace -s 100000'
105
+ run_test = $(quiet_pre) \
106
+ $(rb_setsid) $(TRACER) $(RUBY) -w $(arg) $(TEST_OPTS) $(quiet_post) || \
107
+ (sed "s,^,$(extra): ," >&2 < $(t); exit 1)
108
+
109
+ %.n: arg = $(subst .n,,$(subst --, -n ,$@))
110
+ %.n: t = $(subst .n,$(log_suffix),$@)
111
+ %.n: export PATH := $(test_prefix)/bin:$(PATH)
112
+ %.n: export RUBYLIB := $(test_prefix):$(test_prefix)/lib:$(RUBYLIB)
113
+ %.n: $(test_prefix)/.stamp
114
+ $(run_test)
115
+
116
+ $(T): arg = $@
117
+ $(T): t = $(subst .rb,$(log_suffix),$@)
118
+ $(T): export PATH := $(test_prefix)/bin:$(PATH)
119
+ $(T): export RUBYLIB := $(test_prefix):$(test_prefix)/lib:$(RUBYLIB)
120
+ $(T): $(test_prefix)/.stamp
121
+ $(run_test)
122
+
123
+ install: $(bins) $(ext)/unicorn_http.c
124
+ $(prep_setup_rb)
125
+ $(RM) lib/unicorn_http.$(DLEXT)
126
+ $(RM) -r .install-tmp
127
+ mkdir .install-tmp
128
+ cp -p bin/* .install-tmp
129
+ $(RUBY) setup.rb all
130
+ $(RM) $^
131
+ mv .install-tmp/* bin/
132
+ $(RM) -r .install-tmp
133
+ $(prep_setup_rb)
134
+
135
+ setup_rb_files := .config InstalledFiles
136
+ prep_setup_rb := @-$(RM) $(setup_rb_files);$(MAKE) -C $(ext) clean
137
+
138
+ clean:
139
+ -$(MAKE) -C $(ext) clean
140
+ -$(MAKE) -C Documentation clean
141
+ $(RM) $(ext)/Makefile lib/unicorn_http.$(DLEXT)
142
+ $(RM) $(setup_rb_files) $(t_log)
143
+ $(RM) -r $(test_prefix) man
144
+
145
+ man:
146
+ $(MAKE) -C Documentation install-man
147
+
148
+ pkg_extra := GIT-VERSION-FILE NEWS ChangeLog $(ext)/unicorn_http.c
149
+ manifest: $(pkg_extra) man
150
+ $(RM) .manifest
151
+ $(MAKE) .manifest
152
+
153
+ .manifest:
154
+ (git ls-files && \
155
+ for i in $@ $(pkg_extra) $(man1_paths); \
156
+ do echo $$i; done) | LC_ALL=C sort > $@+
157
+ cmp $@+ $@ || mv $@+ $@
158
+ $(RM) $@+
159
+
160
+ NEWS: GIT-VERSION-FILE .manifest
161
+ $(RAKE) -s news_rdoc > $@+
162
+ mv $@+ $@
163
+
164
+ SINCE = 0.97.1
165
+ ChangeLog: LOG_VERSION = \
166
+ $(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
167
+ echo $(GIT_VERSION) || git describe)
168
+ ChangeLog: log_range = v$(SINCE)..$(LOG_VERSION)
169
+ ChangeLog: GIT-VERSION-FILE
170
+ @echo "ChangeLog from $(GIT_URL) ($(log_range))" > $@+
171
+ @echo >> $@+
172
+ git log $(log_range) | sed -e 's/^/ /' >> $@+
173
+ mv $@+ $@
174
+
175
+ news_atom := http://unicorn.bogomips.org/NEWS.atom.xml
176
+ cgit_atom := http://git.bogomips.org/cgit/unicorn.git/atom/?h=master
177
+ atom = <link rel="alternate" title="Atom feed" href="$(1)" \
178
+ type="application/atom+xml"/>
179
+
180
+ # using rdoc 2.5.x+
181
+ doc: .document $(ext)/unicorn_http.c NEWS ChangeLog
182
+ for i in $(man1_rdoc); do echo > $$i; done
183
+ find bin lib -type f -name '*.rbc' -exec rm -f '{}' ';'
184
+ rdoc -a -t "$(shell sed -ne '1s/^= //p' README)"
185
+ install -m644 COPYING doc/COPYING
186
+ install -m644 $(shell grep '^[A-Z]' .document) doc/
187
+ $(MAKE) -C Documentation install-html install-man
188
+ install -m644 $(man1_paths) doc/
189
+ cd doc && for i in $(base_bins); do \
190
+ $(RM) 1.html $${i}.1.html; \
191
+ sed -e '/"documentation">/r man1/'$$i'.1.html' \
192
+ < $${i}_1.html > tmp && mv tmp $${i}_1.html; \
193
+ ln $${i}_1.html $${i}.1.html; \
194
+ done
195
+ $(RUBY) -i -p -e \
196
+ '$$_.gsub!("</title>",%q{\&$(call atom,$(cgit_atom))})' \
197
+ doc/ChangeLog.html
198
+ $(RUBY) -i -p -e \
199
+ '$$_.gsub!("</title>",%q{\&$(call atom,$(news_atom))})' \
200
+ doc/NEWS.html doc/README.html
201
+ $(RAKE) -s news_atom > doc/NEWS.atom.xml
202
+ cd doc && ln README.html tmp && mv tmp index.html
203
+ $(RM) $(man1_rdoc)
204
+
205
+ rails_git_url = git://github.com/rails/rails.git
206
+ rails_git := vendor/rails.git
207
+ $(rails_git)/info/cloned-stamp:
208
+ git clone --mirror -q $(rails_git_url) $(rails_git)
209
+ > $@
210
+
211
+ rails_tests := $(addsuffix .r,$(addprefix $(T_r).,$(rails_vers)))
212
+ test-rails: $(rails_tests)
213
+ $(T_r).%.r: t = $(addsuffix $(log_suffix),$@)
214
+ $(T_r).%.r: rv = $(subst .r,,$(subst $(T_r).,,$@))
215
+ $(T_r).%.r: extra = ' 'v$(rv)
216
+ $(T_r).%.r: arg = $(T_r)
217
+ $(T_r).%.r: export PATH := $(test_prefix)/bin:$(PATH)
218
+ $(T_r).%.r: export RUBYLIB := $(test_prefix):$(test_prefix)/lib:$(RUBYLIB)
219
+ $(T_r).%.r: export UNICORN_RAILS_TEST_VERSION = $(rv)
220
+ $(T_r).%.r: export RAILS_GIT_REPO = $(CURDIR)/$(rails_git)
221
+ $(T_r).%.r: $(test_prefix)/.stamp $(rails_git)/info/cloned-stamp
222
+ $(run_test)
223
+
224
+ ifneq ($(VERSION),)
225
+ rfproject := mongrel
226
+ rfpackage := unicorn
227
+ pkggem := pkg/$(rfpackage)-$(VERSION).gem
228
+ pkgtgz := pkg/$(rfpackage)-$(VERSION).tgz
229
+ release_notes := release_notes-$(VERSION)
230
+ release_changes := release_changes-$(VERSION)
231
+
232
+ release-notes: $(release_notes)
233
+ release-changes: $(release_changes)
234
+ $(release_changes):
235
+ $(RAKE) -s release_changes > $@+
236
+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
237
+ $(release_notes):
238
+ GIT_URL=$(GIT_URL) $(RAKE) -s release_notes > $@+
239
+ $(VISUAL) $@+ && test -s $@+ && mv $@+ $@
240
+
241
+ # ensures we're actually on the tagged $(VERSION), only used for release
242
+ verify:
243
+ test x"$(shell umask)" = x0022
244
+ git rev-parse --verify refs/tags/v$(VERSION)^{}
245
+ git diff-index --quiet HEAD^0
246
+ test `git rev-parse --verify HEAD^0` = \
247
+ `git rev-parse --verify refs/tags/v$(VERSION)^{}`
248
+
249
+ fix-perms:
250
+ git ls-tree -r HEAD | awk '/^100644 / {print $$NF}' | xargs chmod 644
251
+ git ls-tree -r HEAD | awk '/^100755 / {print $$NF}' | xargs chmod 755
252
+
253
+ gem: $(pkggem)
254
+
255
+ install-gem: $(pkggem)
256
+ gem install $(CURDIR)/$<
257
+
258
+ $(pkggem): manifest fix-perms
259
+ gem build $(rfpackage).gemspec
260
+ mkdir -p pkg
261
+ mv $(@F) $@
262
+
263
+ $(pkgtgz): distdir = $(basename $@)
264
+ $(pkgtgz): HEAD = v$(VERSION)
265
+ $(pkgtgz): manifest fix-perms
266
+ @test -n "$(distdir)"
267
+ $(RM) -r $(distdir)
268
+ mkdir -p $(distdir)
269
+ tar cf - `cat .manifest` | (cd $(distdir) && tar xf -)
270
+ cd pkg && tar cf - $(basename $(@F)) | gzip -9 > $(@F)+
271
+ mv $@+ $@
272
+
273
+ package: $(pkgtgz) $(pkggem)
274
+
275
+ release: verify package $(release_notes) $(release_changes)
276
+ # make tgz release on RubyForge
277
+ rubyforge add_release -f -n $(release_notes) -a $(release_changes) \
278
+ $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
279
+ # push gem to Gemcutter
280
+ gem push $(pkggem)
281
+ # in case of gem downloads from RubyForge releases page
282
+ -rubyforge add_file \
283
+ $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
284
+ $(RAKE) raa_update VERSION=$(VERSION)
285
+ $(RAKE) fm_update VERSION=$(VERSION)
286
+ else
287
+ gem install-gem: GIT-VERSION-FILE
288
+ $(MAKE) $@ VERSION=$(GIT_VERSION)
289
+ endif
290
+
291
+ .PHONY: .FORCE-GIT-VERSION-FILE doc $(T) $(slow_tests) manifest man
292
+ .PHONY: test-install
data/HACKING ADDED
@@ -0,0 +1,116 @@
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 installed
20
+ as "make" instead of "gmake".
21
+
22
+ Since we don't load RubyGems by default, loading Rack properly requires
23
+ setting up RUBYLIB to point to where Rack is located. Not loading
24
+ RubyGems drastically lowers the time to run the full test suite. You
25
+ may setup a "local.mk" file in the top-level working directory to setup
26
+ your RUBYLIB and any other environment variables. A "local.mk.sample"
27
+ file is provided for reference.
28
+
29
+ Running the entire test suite with 4 tests in parallel:
30
+
31
+ gmake -j4 test
32
+
33
+ Running just one unit test:
34
+
35
+ gmake test/unit/test_http_parser.rb
36
+
37
+ Running just one test case in a unit test:
38
+
39
+ gmake test/unit/test_http_parser.rb--test_parse_simple.n
40
+
41
+ === HttpServer
42
+
43
+ We strive to write as little code as possible while still maintaining
44
+ readability. However, readability and flexibility may be sacrificed for
45
+ performance in hot code paths. For Ruby, less code generally means
46
+ faster code.
47
+
48
+ Memory allocation should be minimized as much as practically possible.
49
+ Buffers for IO#readpartial are preallocated in the hot paths to avoid
50
+ building up garbage. Hash assignments use frozen strings to avoid the
51
+ duplication behind-the-scenes.
52
+
53
+ We spend as little time as possible inside signal handlers and instead
54
+ defer handling them for predictability and robustness. Most of the
55
+ Unix-specific things are in the Unicorn::HttpServer class. Unix systems
56
+ programming experience will come in handy (or be learned) here.
57
+
58
+ === Documentation
59
+
60
+ We use RDoc 2.4.x with Darkfish for documentation as much as possible,
61
+ if you're on Ruby 1.8 you want to install the latest "rdoc" gem. Due to
62
+ the lack of RDoc-to-manpage converters we know about, we're writing
63
+ manpages in Markdown and converting to troff/HTML with Pandoc.
64
+
65
+ === Ruby/C Compatibility
66
+
67
+ We target Ruby 1.8.6+, 1.9 and will target Rubinius as it becomes
68
+ production-ready. We need the Ruby implementation to support fork,
69
+ exec, pipe, UNIX signals, access to integer file descriptors and
70
+ 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 and will update our code
78
+ to keep up with new releases. Packaged tarballs and gems include the
79
+ generated source code so they will remain usable if compatibility is
80
+ 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 Documentation/SubmittingPatches document
100
+ distributed with git on on patch submission guidelines to follow. Just
101
+ don't email the git mailing list or maintainer with Unicorn patches :)
102
+
103
+ == Running Development Versions
104
+
105
+ It is easy to install the contents of your git working directory:
106
+
107
+ Via RubyGems (RubyGems 1.3.5+ recommended for prerelease versions):
108
+
109
+ gmake install-gem
110
+
111
+ Without RubyGems (via setup.rb):
112
+
113
+ gmake install
114
+
115
+ It is not at all recommended to mix a RubyGems installation with an
116
+ installation done without RubyGems, however.