unicorn 0.92.0 → 0.93.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document CHANGED
@@ -1,10 +1,12 @@
1
1
  README
2
2
  TUNING
3
3
  PHILOSOPHY
4
+ HACKING
4
5
  DESIGN
5
6
  CONTRIBUTORS
6
7
  LICENSE
7
8
  SIGNALS
9
+ KNOWN_ISSUES
8
10
  TODO
9
11
  NEWS
10
12
  ChangeLog
data/.gitignore CHANGED
@@ -1,6 +1,7 @@
1
1
  *.bundle
2
2
  *.log
3
3
  *.so
4
+ *.rbc
4
5
  .DS_Store
5
6
  /.config
6
7
  /InstalledFiles
@@ -143,6 +143,15 @@ are never loaded by default. If needed, they should be
143
143
  individually specified in the RACKUP_FILE, some frameworks do
144
144
  not require them.
145
145
 
146
+ # ENVIRONMENT VARIABLES
147
+
148
+ All application or library-specific environment variables (e.g. TMPDIR)
149
+ may always be set in the Unicorn CONFIG_FILE in addition to the spawning
150
+ shell. When transparently upgrading Unicorn, all environment variables
151
+ set in the old master process are inherited by the new master process.
152
+ Unicorn only uses (and will overwrite) the UNICORN_FD environment
153
+ variable internally when doing transparent upgrades.
154
+
146
155
  # SEE ALSO
147
156
 
148
157
  * unicorn_rails(1)
@@ -78,6 +78,12 @@ as much as possible.
78
78
  This option only exists for compatibility with the rackup(1) command,
79
79
  use of "-l"/"\--listen" switch is recommended instead.
80
80
 
81
+ \--path PATH
82
+ : Mounts the Rails application at the given PATH (instead of "/").
83
+ This is equivalent to setting the RAILS_RELATIVE_URL_ROOT
84
+ environment variable. This is only supported under Rails 2.3
85
+ or later at the moment.
86
+
81
87
  # RUBY OPTIONS
82
88
  -e, \--eval LINE
83
89
  : Evaluate a LINE of Ruby code. This evaluation happens
@@ -114,6 +120,19 @@ of the default middleware for performance.
114
120
  Embedded command-line options are mostly parsed for compatibility
115
121
  with rackup(1) but strongly discouraged.
116
122
 
123
+ # ENVIRONMENT VARIABLES
124
+
125
+ The RAILS_ENV variable is set by the aforementioned \-E switch. The
126
+ RAILS_RELATIVE_URL_ROOT is set by the aforementioned \--path switch.
127
+ Either of these variables may also be set in the shell or the Unicorn
128
+ CONFIG_FILE. All application or library-specific environment variables
129
+ (e.g. TMPDIR, RAILS_ASSET_ID) may always be set in the Unicorn
130
+ CONFIG_FILE in addition to the spawning shell. When transparently
131
+ upgrading Unicorn, all environment variables set in the old master
132
+ process are inherited by the new master process. Unicorn only uses (and
133
+ will overwrite) the UNICORN_FD environment variable internally when
134
+ doing transparent upgrades.
135
+
117
136
  # SIGNALS
118
137
 
119
138
  The following UNIX signals may be sent to the master process:
data/GIT-VERSION-GEN CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v0.92.0.GIT
4
+ DEF_VER=v0.93.0.GIT
5
5
 
6
6
  LF='
7
7
  '
data/GNUmakefile CHANGED
@@ -3,8 +3,7 @@ all:: test
3
3
  ruby = ruby
4
4
  rake = rake
5
5
  ragel = ragel
6
- GIT_URL = $(shell git config --get remote.origin.url 2>/dev/null || \
7
- echo git://git.bogomips.org/unicorn.git)
6
+ GIT_URL = git://git.bogomips.org/unicorn.git
8
7
  RLFLAGS = -G2
9
8
 
10
9
  GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@@ -37,9 +36,12 @@ test_prefix = $(CURDIR)/test/install-$(RUBY_VERSION)
37
36
  ext := ext/unicorn_http
38
37
  c_files := $(ext)/unicorn_http.c $(wildcard $(ext)/*.h)
39
38
  rl_files := $(wildcard $(ext)/*.rl)
40
- bins := $(wildcard bin/*)
41
- rb_files := $(bins) $(shell find lib -type f -name '*.rb')
42
- inst_deps := $(c_files) $(rb_files)
39
+ base_bins := unicorn unicorn_rails
40
+ bins := $(addprefix bin/, $(base_bins))
41
+ man1_bins := $(addsuffix .1, $(base_bins))
42
+ man1_paths := $(addprefix man/man1/, $(man1_bins))
43
+ rb_files := $(bins) $(shell find lib ext -type f -name '*.rb')
44
+ inst_deps := $(c_files) $(rb_files) GNUmakefile test/test_helper.rb
43
45
 
44
46
  ragel: $(ext)/unicorn_http.c
45
47
  $(ext)/unicorn_http.c: $(rl_files)
@@ -56,7 +58,7 @@ http: lib/unicorn_http.$(DLEXT)
56
58
 
57
59
  $(test_prefix)/.stamp: $(inst_deps)
58
60
  mkdir -p $(test_prefix)/.ccache
59
- tar c `cat .manifest` | (cd $(test_prefix) && tar x)
61
+ tar c $(inst_deps) GIT-VERSION-GEN | (cd $(test_prefix) && tar x)
60
62
  $(MAKE) -C $(test_prefix) clean
61
63
  $(MAKE) -C $(test_prefix) http shebang
62
64
  > $@
@@ -111,6 +113,7 @@ $(T): $(test_prefix)/.stamp
111
113
 
112
114
  install: $(bins) $(ext)/unicorn_http.c
113
115
  $(prep_setup_rb)
116
+ $(RM) lib/unicorn_http.$(DLEXT)
114
117
  $(RM) -r .install-tmp
115
118
  mkdir .install-tmp
116
119
  cp -p bin/* .install-tmp
@@ -132,10 +135,15 @@ clean:
132
135
 
133
136
  man:
134
137
  $(MAKE) -C Documentation install-man
135
- .manifest: GIT-VERSION-FILE NEWS ChangeLog $(ext)/unicorn_http.c
136
- $(MAKE) man
138
+
139
+ pkg_extra := GIT-VERSION-FILE NEWS ChangeLog $(ext)/unicorn_http.c
140
+ manifest: $(pkg_extra) man
141
+ $(RM) .manifest
142
+ $(MAKE) .manifest
143
+
144
+ .manifest:
137
145
  (git ls-files && \
138
- for i in $@ $^ $(wildcard man/*/*.1); \
146
+ for i in $@ $(pkg_extra) $(man1_paths); \
139
147
  do echo $$i; done) | LC_ALL=C sort > $@+
140
148
  cmp $@+ $@ || mv $@+ $@
141
149
  $(RM) $@+
@@ -144,10 +152,12 @@ NEWS: GIT-VERSION-FILE
144
152
  $(rake) -s news_rdoc > $@+
145
153
  mv $@+ $@
146
154
 
155
+ SINCE = 0.92.0
156
+ ChangeLog: log_range = $(shell test -n "$(SINCE)" && echo v$(SINCE)..)
147
157
  ChangeLog: GIT-VERSION-FILE
148
- @echo "ChangeLog from $(GIT_URL) ($(GIT_VERSION))" > $@+
158
+ @echo "ChangeLog from $(GIT_URL) ($(SINCE)..$(GIT_VERSION))" > $@+
149
159
  @echo >> $@+
150
- git log | sed -e 's/^/ /' >> $@+
160
+ git log $(log_range) | sed -e 's/^/ /' >> $@+
151
161
  mv $@+ $@
152
162
 
153
163
  news_atom := http://unicorn.bogomips.org/NEWS.atom.xml
@@ -157,11 +167,12 @@ atom = <link rel="alternate" title="Atom feed" href="$(1)" \
157
167
 
158
168
  # using rdoc 2.4.1+
159
169
  doc: .document $(ext)/unicorn_http.c NEWS ChangeLog
160
- > unicorn.1 && > unicorn_rails.1
170
+ for i in $(man1_bins); do > $$i; done
161
171
  rdoc -Na -t "$(shell sed -ne '1s/^= //p' README)"
162
172
  install -m644 $(shell grep '^[A-Z]' .document) doc/
163
- $(MAKE) -C Documentation install-html
164
- cd doc && for i in unicorn unicorn_rails; do \
173
+ $(MAKE) -C Documentation install-html install-man
174
+ install -m644 $(man1_paths) doc/
175
+ cd doc && for i in $(base_bins); do \
165
176
  sed -e '/"documentation">/r man1/'$$i'.1.html' \
166
177
  < $${i}_1.html > tmp && mv tmp $${i}_1.html; done
167
178
  $(ruby) -i -p -e \
@@ -172,7 +183,7 @@ doc: .document $(ext)/unicorn_http.c NEWS ChangeLog
172
183
  doc/NEWS.html doc/README.html
173
184
  $(rake) -s news_atom > doc/NEWS.atom.xml
174
185
  cd doc && ln README.html tmp && mv tmp index.html
175
- $(RM) unicorn.1 unicorn_rails.1
186
+ $(RM) $(man1_bins)
176
187
 
177
188
  rails_git_url = git://github.com/rails/rails.git
178
189
  rails_git := vendor/rails.git
@@ -217,14 +228,19 @@ verify:
217
228
  test `git rev-parse --verify HEAD^0` = \
218
229
  `git rev-parse --verify refs/tags/v$(VERSION)^{}`
219
230
 
220
- $(pkggem): .manifest
231
+ gem: $(pkggem)
232
+
233
+ install-gem: $(pkggem)
234
+ gem install $(CURDIR)/$<
235
+
236
+ $(pkggem): manifest
221
237
  gem build $(rfpackage).gemspec
222
238
  mkdir -p pkg
223
239
  mv $(@F) $@
224
240
 
225
241
  $(pkgtgz): distdir = $(basename $@)
226
242
  $(pkgtgz): HEAD = v$(VERSION)
227
- $(pkgtgz): .manifest
243
+ $(pkgtgz): manifest
228
244
  @test -n "$(distdir)"
229
245
  $(RM) -r $(distdir)
230
246
  mkdir -p $(distdir)
@@ -239,6 +255,9 @@ release: verify package $(release_notes) $(release_changes)
239
255
  $(rfproject) $(rfpackage) $(VERSION) $(pkggem)
240
256
  rubyforge add_file \
241
257
  $(rfproject) $(rfpackage) $(VERSION) $(pkgtgz)
258
+ else
259
+ gem install-gem: GIT-VERSION-FILE
260
+ $(MAKE) $@ VERSION=$(GIT_VERSION)
242
261
  endif
243
262
 
244
- .PHONY: .FORCE-GIT-VERSION-FILE doc $(T) $(slow_tests) .manifest man
263
+ .PHONY: .FORCE-GIT-VERSION-FILE doc $(T) $(slow_tests) manifest man
data/HACKING ADDED
@@ -0,0 +1,113 @@
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
+ Since we don't load RubyGems by default, loading Rack properly requires
20
+ setting up RUBYLIB to point to where Rack is located. Not loading
21
+ Rubygems drastically lowers the time to run the full test suite. You
22
+ may setup a "local.mk" file in the top-level working directory to setup
23
+ your RUBYLIB and any other environment variables. A "local.mk.sample"
24
+ file is provided for reference.
25
+
26
+ Running the entire test suite with 4 tests in parallel:
27
+
28
+ make -j4 test
29
+
30
+ Running just one unit test:
31
+
32
+ make test/unit/test_http_parser.rb
33
+
34
+ Running just one test case in a unit test:
35
+
36
+ make test/unit/test_http_parser.rb--test_parse_simple.n
37
+
38
+ === HttpServer
39
+
40
+ We strive to write as little code as possible while still maintaining
41
+ readability. However, readability and flexibility may be sacrificed for
42
+ performance in hot code paths. For Ruby, less code generally means
43
+ faster code.
44
+
45
+ Memory allocation should be minimized as much as practically possible.
46
+ Buffers for IO#readpartial are preallocated in the hot paths to avoid
47
+ building up garbage. Hash assignments use frozen strings to avoid the
48
+ duplication behind-the-scenes.
49
+
50
+ We spend as little time as possible inside signal handlers and instead
51
+ defer handling them for predictability and robustness. Most of the
52
+ Unix-specific things are in the Unicorn::HttpServer class. Unix systems
53
+ programming experience will come in handy (or be learned) here.
54
+
55
+ === Documentation
56
+
57
+ We use RDoc 2.4.x with Darkfish for documentation as much as possible,
58
+ if you're on Ruby 1.8 you want to install the latest "rdoc" gem. Due to
59
+ the lack of RDoc-to-manpage converters we know about, we're writing
60
+ manpages in Markdown and converting to troff/HTML with Pandoc.
61
+
62
+ === Ruby/C Compatibility
63
+
64
+ We target Ruby 1.8.6+, 1.9 and will target Rubinius as it becomes
65
+ production-ready. We need the Ruby implementation to support fork,
66
+ exec, pipe, UNIX signals, access to integer file descriptors and
67
+ ability to use unlinked files.
68
+
69
+ All of our C code is OS-independent and should run on compilers
70
+ supported by the versions of Ruby we target.
71
+
72
+ === Ragel Compatibility
73
+
74
+ We target the latest released version of Ragel and will update our code
75
+ to keep up with new releases. Packaged tarballs and gems include the
76
+ generated source code so they will remain usable if compatibility is
77
+ broken.
78
+
79
+ == Contributing
80
+
81
+ Contributions are welcome in the form of patches, pull requests, code
82
+ review, testing, documentation, user support or any other feedback is
83
+ welcome. The mailing list is the central coordination point for all
84
+ user and developer feedback and bug reports.
85
+
86
+ === Submitting Patches
87
+
88
+ Follow conventions already established in the code and do not exceed 80
89
+ characters per line.
90
+
91
+ Inline patches (from "git format-patch") to the mailing list are
92
+ preferred because they allow code review and comments in the reply to
93
+ the patch.
94
+
95
+ We will adhere to mostly the same conventions for patch submissions as
96
+ git itself. See the Documentation/SubmittingPatches 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
+ == Running Development Versions
101
+
102
+ It is easy to install the contents of your git working directory:
103
+
104
+ Via RubyGems (RubyGems 1.3.5+ recommended for prerelease versions):
105
+
106
+ make install-gem
107
+
108
+ Without RubyGems (via setup.rb):
109
+
110
+ make install
111
+
112
+ It is not at all recommended to mix a RubyGems installation with an
113
+ installation done without RubyGems, however.
data/KNOWN_ISSUES ADDED
@@ -0,0 +1,27 @@
1
+ = Known Issues
2
+
3
+ * Installing "unicorn" as a system-wide Rubygem and using the
4
+ {isolate}[http://github.com/jbarnette/isolate] gem may cause issues if
5
+ you're using any of the bundled application-level libraries in
6
+ unicorn/app/* (for compatibility with CGI-based applications, Rails <=
7
+ 2.2.2, or ExecCgi). For now workarounds include:
8
+
9
+ * installing the same version of unicorn as a system-wide Rubygem
10
+ _and_ isolating unicorn as well.
11
+ * explicitly setting RUBYLIB or $LOAD_PATH to include any gem path
12
+ where the unicorn gem is installed (e.g.
13
+ /usr/lib/ruby/gems/1.8/gems/unicorn-VERSION/lib)
14
+
15
+ * WONTFIX: code reloading and restarts with Sinatra 0.3.x (and likely older
16
+ versions) apps is broken. The workaround is to force production
17
+ mode to disable code reloading as well as disabling "run" in your
18
+ Sinatra application:
19
+ set :env, :production
20
+ set :run, false
21
+ Since this is no longer an issue with Sinatra 0.9.x apps, this will not be
22
+ fixed on our end. Since Unicorn is itself the application launcher, the
23
+ at_exit handler used in old Sinatra always caused Mongrel to be launched
24
+ whenever a Unicorn worker was about to exit.
25
+
26
+ Also remember we're capable of replacing the running binary without dropping
27
+ any connections regardless of framework :)
data/README CHANGED
@@ -1,5 +1,11 @@
1
1
  = Unicorn: Rack HTTP server for Unix and fast clients
2
2
 
3
+ Unicorn is a HTTP server for Rack applications designed to take
4
+ advantage of features in Unix/Unix-like kernels and only serve fast
5
+ clients on low-latency, high-bandwidth connections. Slow clients should
6
+ only be served by placing a reverse proxy capable of fully-buffering
7
+ both the the request and response in between Unicorn and slow clients.
8
+
3
9
  == Features
4
10
 
5
11
  * Designed for Rack, Unix, fast clients, and ease-of-debugging. We
@@ -51,12 +57,6 @@
51
57
  notification to be implemented as well as being able to tunnel
52
58
  arbitrary stream-based protocols over HTTP.
53
59
 
54
- == Versions
55
-
56
- {Current v0.92.0}[http://git.bogomips.org/cgit/unicorn.git/tag/?id=v0.92.0]
57
-
58
- {Old Stable v0.8.4}[http://git.bogomips.org/cgit/unicorn.git/tag/?id=v0.8.4]
59
-
60
60
  == License
61
61
 
62
62
  Unicorn is copyright 2009 Eric Wong and contributors.
@@ -138,22 +138,6 @@ Unicorn is designed to only serve fast clients either on the local host
138
138
  or a fast LAN. See the PHILOSOPHY and DESIGN documents for more details
139
139
  regarding this.
140
140
 
141
- == Known Issues
142
-
143
- * WONTFIX: code reloading and restarts with Sinatra 0.3.x (and likely older
144
- versions) apps is broken. The workaround is to force production
145
- mode to disable code reloading as well as disabling "run" in your
146
- Sinatra application:
147
- set :env, :production
148
- set :run, false
149
- Since this is no longer an issue with Sinatra 0.9.x apps, this will not be
150
- fixed on our end. Since Unicorn is itself the application launcher, the
151
- at_exit handler used in old Sinatra always caused Mongrel to be launched
152
- whenever a Unicorn worker was about to exit.
153
-
154
- Also remember we're capable of replacing the running binary without dropping
155
- any connections regardless of framework :)
156
-
157
141
  == Contact
158
142
 
159
143
  All feedback (bug reports, user/development dicussion, patches, pull
data/Rakefile CHANGED
@@ -93,9 +93,7 @@ desc "print release notes for Rubyforge"
93
93
  task :release_notes do
94
94
  require 'rubygems'
95
95
 
96
- git_url = ENV['GIT_URL'] ||
97
- `git config --get remote.origin.url 2>/dev/null`.chomp! ||
98
- 'git://git.bogomips.org/unicorn.git'
96
+ git_url = ENV['GIT_URL'] || 'git://git.bogomips.org/unicorn.git'
99
97
 
100
98
  spec = Gem::Specification.load('unicorn.gemspec')
101
99
  puts spec.description.strip
data/SIGNALS CHANGED
@@ -2,7 +2,10 @@
2
2
 
3
3
  In general, signals need only be sent to the master process. However,
4
4
  the signals Unicorn uses internally to communicate with the worker
5
- processes are documented here as well.
5
+ processes are documented here as well. With the exception of TTIN/TTOU,
6
+ signal handling matches the behavior of {nginx}[http://nginx.net/] so it
7
+ should be possible to easily share process management scripts between
8
+ Unicorn and nginx.
6
9
 
7
10
  === Master Process
8
11
 
data/TUNING CHANGED
@@ -12,6 +12,12 @@ See Unicorn::Configurator for details on the config file format.
12
12
  directives can allow failover to happen more quickly if your
13
13
  cluster is configured for it.
14
14
 
15
+ * If you're doing extremely simple benchmarks and getting connection
16
+ errors under high request rates, increasing your :backlog parameter
17
+ above the already-generous default of 1024 can help avoid connection
18
+ errors. Keep in mind this is not recommended for real traffic if
19
+ you have another machine to failover to (see above).
20
+
15
21
  * :rcvbuf and :sndbuf parameters generally do not need to be set for TCP
16
22
  listeners under Linux 2.6 because auto-tuning is enabled. UNIX domain
17
23
  sockets do not have auto-tuning buffer sizes; so increasing those will
@@ -45,7 +51,8 @@ WARNING: Do not change system parameters unless you know what you're doing!
45
51
 
46
52
  * For load testing/benchmarking with UNIX domain sockets, you should
47
53
  consider increasing net.core.somaxconn or else nginx will start
48
- failing to connect under heavy load.
54
+ failing to connect under heavy load. You may also consider setting
55
+ a higher :backlog to listen on as noted earlier.
49
56
 
50
57
  * If you're running out of local ports, consider lowering
51
58
  net.ipv4.tcp_fin_timeout to 20-30 (default: 60 seconds). Also