unicorn-heroku 4.3.1.1.gc608.dirty

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. data/.CHANGELOG.old +25 -0
  2. data/.document +29 -0
  3. data/.gitignore +24 -0
  4. data/.mailmap +26 -0
  5. data/.wrongdoc.yml +10 -0
  6. data/Application_Timeouts +77 -0
  7. data/CONTRIBUTORS +35 -0
  8. data/COPYING +674 -0
  9. data/DESIGN +97 -0
  10. data/Documentation/.gitignore +5 -0
  11. data/Documentation/GNUmakefile +30 -0
  12. data/Documentation/unicorn.1.txt +174 -0
  13. data/Documentation/unicorn_rails.1.txt +175 -0
  14. data/FAQ +53 -0
  15. data/GIT-VERSION-GEN +40 -0
  16. data/GNUmakefile +294 -0
  17. data/HACKING +134 -0
  18. data/ISSUES +36 -0
  19. data/KNOWN_ISSUES +79 -0
  20. data/LICENSE +64 -0
  21. data/Links +56 -0
  22. data/PHILOSOPHY +145 -0
  23. data/README +154 -0
  24. data/Rakefile +97 -0
  25. data/SIGNALS +114 -0
  26. data/Sandbox +96 -0
  27. data/TODO +5 -0
  28. data/TUNING +98 -0
  29. data/bin/unicorn +121 -0
  30. data/bin/unicorn_rails +209 -0
  31. data/examples/big_app_gc.rb +2 -0
  32. data/examples/echo.ru +27 -0
  33. data/examples/git.ru +13 -0
  34. data/examples/init.sh +74 -0
  35. data/examples/logger_mp_safe.rb +25 -0
  36. data/examples/logrotate.conf +29 -0
  37. data/examples/nginx.conf +156 -0
  38. data/examples/unicorn.conf.minimal.rb +13 -0
  39. data/examples/unicorn.conf.rb +94 -0
  40. data/ext/unicorn_http/CFLAGS +13 -0
  41. data/ext/unicorn_http/c_util.h +124 -0
  42. data/ext/unicorn_http/common_field_optimization.h +111 -0
  43. data/ext/unicorn_http/ext_help.h +86 -0
  44. data/ext/unicorn_http/extconf.rb +10 -0
  45. data/ext/unicorn_http/global_variables.h +97 -0
  46. data/ext/unicorn_http/httpdate.c +82 -0
  47. data/ext/unicorn_http/unicorn_http.rl +1036 -0
  48. data/ext/unicorn_http/unicorn_http_common.rl +76 -0
  49. data/lib/unicorn.rb +107 -0
  50. data/lib/unicorn/app/exec_cgi.rb +154 -0
  51. data/lib/unicorn/app/inetd.rb +109 -0
  52. data/lib/unicorn/app/old_rails.rb +35 -0
  53. data/lib/unicorn/app/old_rails/static.rb +59 -0
  54. data/lib/unicorn/cgi_wrapper.rb +147 -0
  55. data/lib/unicorn/configurator.rb +630 -0
  56. data/lib/unicorn/const.rb +40 -0
  57. data/lib/unicorn/http_request.rb +77 -0
  58. data/lib/unicorn/http_response.rb +45 -0
  59. data/lib/unicorn/http_server.rb +744 -0
  60. data/lib/unicorn/launcher.rb +62 -0
  61. data/lib/unicorn/oob_gc.rb +71 -0
  62. data/lib/unicorn/preread_input.rb +33 -0
  63. data/lib/unicorn/socket_helper.rb +208 -0
  64. data/lib/unicorn/ssl_client.rb +11 -0
  65. data/lib/unicorn/ssl_configurator.rb +104 -0
  66. data/lib/unicorn/ssl_server.rb +42 -0
  67. data/lib/unicorn/stream_input.rb +149 -0
  68. data/lib/unicorn/tee_input.rb +126 -0
  69. data/lib/unicorn/tmpio.rb +29 -0
  70. data/lib/unicorn/util.rb +68 -0
  71. data/lib/unicorn/worker.rb +88 -0
  72. data/local.mk.sample +59 -0
  73. data/script/isolate_for_tests +50 -0
  74. data/setup.rb +1586 -0
  75. data/t/.gitignore +5 -0
  76. data/t/GNUmakefile +82 -0
  77. data/t/README +42 -0
  78. data/t/bin/content-md5-put +36 -0
  79. data/t/bin/sha1sum.rb +17 -0
  80. data/t/bin/unused_listen +40 -0
  81. data/t/bin/utee +12 -0
  82. data/t/broken-app.ru +12 -0
  83. data/t/detach.ru +11 -0
  84. data/t/env.ru +3 -0
  85. data/t/heartbeat-timeout.ru +12 -0
  86. data/t/my-tap-lib.sh +201 -0
  87. data/t/oob_gc.ru +21 -0
  88. data/t/oob_gc_path.ru +21 -0
  89. data/t/pid.ru +3 -0
  90. data/t/preread_input.ru +17 -0
  91. data/t/rack-input-tests.ru +21 -0
  92. data/t/rails3-app/.gitignore +4 -0
  93. data/t/rails3-app/Gemfile +26 -0
  94. data/t/rails3-app/Rakefile +10 -0
  95. data/t/rails3-app/app/controllers/application_controller.rb +4 -0
  96. data/t/rails3-app/app/helpers/application_helper.rb +2 -0
  97. data/t/rails3-app/app/views/layouts/application.html.erb +14 -0
  98. data/t/rails3-app/config.ru +4 -0
  99. data/t/rails3-app/config/application.rb +46 -0
  100. data/t/rails3-app/config/boot.rb +6 -0
  101. data/t/rails3-app/config/database.yml +22 -0
  102. data/t/rails3-app/config/environment.rb +5 -0
  103. data/t/rails3-app/config/environments/development.rb +19 -0
  104. data/t/rails3-app/config/environments/production.rb +42 -0
  105. data/t/rails3-app/config/environments/test.rb +32 -0
  106. data/t/rails3-app/config/initializers/backtrace_silencers.rb +7 -0
  107. data/t/rails3-app/config/initializers/inflections.rb +10 -0
  108. data/t/rails3-app/config/initializers/mime_types.rb +5 -0
  109. data/t/rails3-app/config/initializers/secret_token.rb +7 -0
  110. data/t/rails3-app/config/initializers/session_store.rb +8 -0
  111. data/t/rails3-app/config/locales/en.yml +5 -0
  112. data/t/rails3-app/config/routes.rb +58 -0
  113. data/t/rails3-app/db/seeds.rb +7 -0
  114. data/t/rails3-app/doc/README_FOR_APP +2 -0
  115. data/t/rails3-app/lib/tasks/.gitkeep +0 -0
  116. data/t/rails3-app/public/404.html +1 -0
  117. data/t/rails3-app/public/500.html +1 -0
  118. data/t/rails3-app/public/x.txt +1 -0
  119. data/t/rails3-app/script/rails +9 -0
  120. data/t/rails3-app/test/performance/browsing_test.rb +9 -0
  121. data/t/rails3-app/test/test_helper.rb +13 -0
  122. data/t/rails3-app/vendor/plugins/.gitkeep +0 -0
  123. data/t/sslgen.sh +71 -0
  124. data/t/t0000-http-basic.sh +50 -0
  125. data/t/t0001-reload-bad-config.sh +53 -0
  126. data/t/t0002-config-conflict.sh +49 -0
  127. data/t/t0002-parser-error.sh +94 -0
  128. data/t/t0003-working_directory.sh +51 -0
  129. data/t/t0004-heartbeat-timeout.sh +69 -0
  130. data/t/t0004-working_directory_broken.sh +24 -0
  131. data/t/t0005-working_directory_app.rb.sh +37 -0
  132. data/t/t0006-reopen-logs.sh +83 -0
  133. data/t/t0006.ru +13 -0
  134. data/t/t0007-working_directory_no_embed_cli.sh +44 -0
  135. data/t/t0008-back_out_of_upgrade.sh +110 -0
  136. data/t/t0009-broken-app.sh +56 -0
  137. data/t/t0009-winch_ttin.sh +59 -0
  138. data/t/t0010-reap-logging.sh +55 -0
  139. data/t/t0011-active-unix-socket.sh +79 -0
  140. data/t/t0012-reload-empty-config.sh +85 -0
  141. data/t/t0013-rewindable-input-false.sh +24 -0
  142. data/t/t0013.ru +12 -0
  143. data/t/t0014-rewindable-input-true.sh +24 -0
  144. data/t/t0014.ru +12 -0
  145. data/t/t0015-configurator-internals.sh +25 -0
  146. data/t/t0016-trust-x-forwarded-false.sh +30 -0
  147. data/t/t0017-trust-x-forwarded-true.sh +30 -0
  148. data/t/t0018-write-on-close.sh +23 -0
  149. data/t/t0019-max_header_len.sh +49 -0
  150. data/t/t0020-at_exit-handler.sh +49 -0
  151. data/t/t0021-process_detach.sh +29 -0
  152. data/t/t0100-rack-input-tests.sh +124 -0
  153. data/t/t0116-client_body_buffer_size.sh +80 -0
  154. data/t/t0116.ru +16 -0
  155. data/t/t0300-rails3-basic.sh +28 -0
  156. data/t/t0301-rails3-missing-config-ru.sh +33 -0
  157. data/t/t0302-rails3-alt-working_directory.sh +32 -0
  158. data/t/t0303-rails3-alt-working_directory_config.ru.sh +56 -0
  159. data/t/t0304-rails3-alt-working_directory_no_embed_cli.sh +52 -0
  160. data/t/t0600-https-server-basic.sh +48 -0
  161. data/t/t9000-preread-input.sh +48 -0
  162. data/t/t9001-oob_gc.sh +47 -0
  163. data/t/t9002-oob_gc-path.sh +75 -0
  164. data/t/test-lib.sh +113 -0
  165. data/t/test-rails3.sh +27 -0
  166. data/t/write-on-close.ru +11 -0
  167. data/test/aggregate.rb +15 -0
  168. data/test/benchmark/README +50 -0
  169. data/test/benchmark/dd.ru +18 -0
  170. data/test/benchmark/stack.ru +8 -0
  171. data/test/exec/README +5 -0
  172. data/test/exec/test_exec.rb +1055 -0
  173. data/test/rails/app-1.2.3/.gitignore +2 -0
  174. data/test/rails/app-1.2.3/Rakefile +7 -0
  175. data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
  176. data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
  177. data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
  178. data/test/rails/app-1.2.3/config/boot.rb +11 -0
  179. data/test/rails/app-1.2.3/config/database.yml +12 -0
  180. data/test/rails/app-1.2.3/config/environment.rb +13 -0
  181. data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
  182. data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
  183. data/test/rails/app-1.2.3/config/routes.rb +6 -0
  184. data/test/rails/app-1.2.3/db/.gitignore +0 -0
  185. data/test/rails/app-1.2.3/public/404.html +1 -0
  186. data/test/rails/app-1.2.3/public/500.html +1 -0
  187. data/test/rails/app-2.0.2/.gitignore +2 -0
  188. data/test/rails/app-2.0.2/Rakefile +7 -0
  189. data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
  190. data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
  191. data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
  192. data/test/rails/app-2.0.2/config/boot.rb +11 -0
  193. data/test/rails/app-2.0.2/config/database.yml +12 -0
  194. data/test/rails/app-2.0.2/config/environment.rb +17 -0
  195. data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
  196. data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
  197. data/test/rails/app-2.0.2/config/routes.rb +6 -0
  198. data/test/rails/app-2.0.2/db/.gitignore +0 -0
  199. data/test/rails/app-2.0.2/public/404.html +1 -0
  200. data/test/rails/app-2.0.2/public/500.html +1 -0
  201. data/test/rails/app-2.1.2/.gitignore +2 -0
  202. data/test/rails/app-2.1.2/Rakefile +7 -0
  203. data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
  204. data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
  205. data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
  206. data/test/rails/app-2.1.2/config/boot.rb +111 -0
  207. data/test/rails/app-2.1.2/config/database.yml +12 -0
  208. data/test/rails/app-2.1.2/config/environment.rb +17 -0
  209. data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
  210. data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
  211. data/test/rails/app-2.1.2/config/routes.rb +6 -0
  212. data/test/rails/app-2.1.2/db/.gitignore +0 -0
  213. data/test/rails/app-2.1.2/public/404.html +1 -0
  214. data/test/rails/app-2.1.2/public/500.html +1 -0
  215. data/test/rails/app-2.2.2/.gitignore +2 -0
  216. data/test/rails/app-2.2.2/Rakefile +7 -0
  217. data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
  218. data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
  219. data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
  220. data/test/rails/app-2.2.2/config/boot.rb +111 -0
  221. data/test/rails/app-2.2.2/config/database.yml +12 -0
  222. data/test/rails/app-2.2.2/config/environment.rb +17 -0
  223. data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
  224. data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
  225. data/test/rails/app-2.2.2/config/routes.rb +6 -0
  226. data/test/rails/app-2.2.2/db/.gitignore +0 -0
  227. data/test/rails/app-2.2.2/public/404.html +1 -0
  228. data/test/rails/app-2.2.2/public/500.html +1 -0
  229. data/test/rails/test_rails.rb +287 -0
  230. data/test/test_helper.rb +300 -0
  231. data/test/unit/test_configurator.rb +158 -0
  232. data/test/unit/test_droplet.rb +28 -0
  233. data/test/unit/test_http_parser.rb +860 -0
  234. data/test/unit/test_http_parser_ng.rb +716 -0
  235. data/test/unit/test_http_parser_xftrust.rb +38 -0
  236. data/test/unit/test_request.rb +197 -0
  237. data/test/unit/test_response.rb +99 -0
  238. data/test/unit/test_server.rb +289 -0
  239. data/test/unit/test_signals.rb +207 -0
  240. data/test/unit/test_sni_hostnames.rb +47 -0
  241. data/test/unit/test_socket_helper.rb +192 -0
  242. data/test/unit/test_stream_input.rb +204 -0
  243. data/test/unit/test_tee_input.rb +296 -0
  244. data/test/unit/test_upload.rb +306 -0
  245. data/test/unit/test_util.rb +100 -0
  246. data/unicorn-heroku.gemspec +44 -0
  247. metadata +426 -0
data/ISSUES ADDED
@@ -0,0 +1,36 @@
1
+ = Issues
2
+
3
+ The {mailing list}[mailto:mongrel-unicorn@rubyforge.org] is the best
4
+ place to report bugs, submit patches and/or obtain support after you
5
+ have searched the mailing list archives and
6
+ {documentation}[http://unicorn.bogomips.org].
7
+
8
+ * No subscription is needed to post to the mailing list,
9
+ let us know that we need to Cc: replies to you if you're unsubscribed.
10
+ * Do not {top post}[http://catb.org/jargon/html/T/top-post.html] in replies
11
+ * Quote only the relevant portions of the message you're replying to
12
+ * Do not send HTML mail
13
+
14
+ If your issue is of a sensitive nature or you're just shy in public,
15
+ then feel free to email us privately at mailto:unicorn@bogomips.org
16
+ instead and your issue will be handled discreetly.
17
+
18
+ If you don't get a response within a few days, we may have forgotten
19
+ about it so feel free to ask again.
20
+
21
+ == Submitting Patches
22
+
23
+ See the HACKING document (and additionally, the
24
+ Documentation/SubmittingPatches document distributed with git) on
25
+ guidelines for patch submission.
26
+
27
+ == Mailing List Info
28
+
29
+ * subscribe: http://rubyforge.org/mailman/listinfo/mongrel-unicorn
30
+ * post: mailto:mongrel-unicorn@rubyforge.org
31
+ * private: mailto:unicorn@bogomips.org
32
+
33
+ == Mailing List Archives
34
+
35
+ * nntp://news.gmane.org/gmane.comp.lang.ruby.unicorn.general
36
+ * http://rubyforge.org/pipermail/mongrel-unicorn
@@ -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
+ http://mid.gmane.org/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
+ * Under some versions of Ruby 1.8, it is necessary to call +srand+ in an
21
+ after_fork hook to get correct random number generation. We have a builtin
22
+ workaround for this starting with \Unicorn 3.6.1
23
+
24
+ See http://redmine.ruby-lang.org/issues/show/4338
25
+
26
+ * On Ruby 1.8 prior to Ruby 1.8.7-p248, *BSD platforms have a broken
27
+ stdio that causes failure for file uploads larger than 112K. Upgrade
28
+ your version of Ruby or continue using Unicorn 1.x/3.4.x.
29
+
30
+ * For notes on sandboxing tools such as Bundler or Isolate,
31
+ see the {Sandbox}[link:Sandbox.html] page.
32
+
33
+ * nginx with "sendfile on" under FreeBSD 8 is broken when
34
+ uploads are buffered to disk. Disabling sendfile is required to
35
+ work around this bug which should be fixed in newer versions of FreeBSD.
36
+
37
+ * When using "preload_app true", with apps using background threads
38
+ need to restart them in the after_fork hook because threads are never
39
+ shared with child processes. Additionally, any synchronization
40
+ primitives (Mutexes, Monitors, ConditionVariables) should be
41
+ reinitialized in case they are held during fork time to avoid
42
+ deadlocks. The core Ruby Logger class needlessly uses a MonitorMutex
43
+ which can be disabled with a {monkey patch}[link:examples/logger_mp_safe.rb]
44
+
45
+ == Known Issues (Old)
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://redmine.ruby-lang.org/issues/show/2962 for more details
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: http://mid.gmane.org/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,64 @@
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), version {3.0}[http://www.gnu.org/licenses/gpl-3.0.txt]
7
+ or version {2.0}[http://www.gnu.org/licenses/gpl-2.0.txt]
8
+ or the Ruby-specific license terms (see below).
9
+
10
+ The unicorn project leader (Eric Wong) reserves the right to add future
11
+ versions of the GPL (and no other licenses) as published by the FSF to
12
+ the licensing terms.
13
+
14
+ === Ruby-specific terms (if you're not using the GPLv2 or GPLv3)
15
+
16
+ 1. You may make and give away verbatim copies of the source form of the
17
+ software without restriction, provided that you duplicate all of the
18
+ original copyright notices and associated disclaimers.
19
+
20
+ 2. You may modify your copy of the software in any way, provided that
21
+ you do at least ONE of the following:
22
+
23
+ a) place your modifications in the Public Domain or otherwise make them
24
+ Freely Available, such as by posting said modifications to Usenet or an
25
+ equivalent medium, or by allowing the author to include your
26
+ modifications in the software.
27
+
28
+ b) use the modified software only within your corporation or
29
+ organization.
30
+
31
+ c) rename any non-standard executables so the names do not conflict with
32
+ standard executables, which must also be provided.
33
+
34
+ d) make other distribution arrangements with the author.
35
+
36
+ 3. You may distribute the software in object code or executable
37
+ form, provided that you do at least ONE of the following:
38
+
39
+ a) distribute the executables and library files of the software,
40
+ together with instructions (in the manual page or equivalent) on where
41
+ to get the original distribution.
42
+
43
+ b) accompany the distribution with the machine-readable source of the
44
+ software.
45
+
46
+ c) give non-standard executables non-standard names, with
47
+ instructions on where to get the original software distribution.
48
+
49
+ d) make other distribution arrangements with the author.
50
+
51
+ 4. You may modify and include the part of the software into any other
52
+ software (possibly commercial). But some files in the distribution
53
+ are not written by the author, so that they are not under this terms.
54
+
55
+ 5. The scripts and library files supplied as input to or produced as
56
+ output from the software do not automatically fall under the
57
+ copyright of the software, but belong to whomever generated them,
58
+ and may be sold commercially, and may be aggregated with this
59
+ software.
60
+
61
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
62
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
63
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
64
+ PURPOSE.
data/Links ADDED
@@ -0,0 +1,56 @@
1
+ = Related Projects
2
+
3
+ If you're interested in \Unicorn, you may be interested in some of the projects
4
+ listed below. If you have any links to add/change/remove, please tell us at
5
+ mailto:mongrel-unicorn@rubyforge.org!
6
+
7
+ == Disclaimer
8
+
9
+ The \Unicorn project is not responsible for the content in these links.
10
+ Furthermore, the \Unicorn project has never, does not and will never endorse:
11
+
12
+ * any for-profit entities or services
13
+ * any non-{Free Software}[http://www.gnu.org/philosophy/free-sw.html]
14
+
15
+ The existence of these links does not imply endorsement of any entities
16
+ or services behind them.
17
+
18
+ === For use with \Unicorn
19
+
20
+ * {Bluepill}[https://github.com/arya/bluepill] -
21
+ a simple process monitoring tool written in Ruby
22
+
23
+ * {golden_brindle}[https://github.com/simonoff/golden_brindle] - tool to
24
+ manage multiple \Unicorn instances/applications on a single server
25
+
26
+ * {raindrops}[http://raindrops.bogomips.org/] - real-time stats for
27
+ preforking Rack servers
28
+
29
+ * {UnXF}[http://bogomips.org/unxf/] Un-X-Forward* the Rack environment,
30
+ useful since unicorn is designed to be deployed behind a reverse proxy.
31
+
32
+ === \Unicorn is written to work with
33
+
34
+ * {Rack}[http://rack.rubyforge.org/] - a minimal interface between webservers
35
+ supporting Ruby and Ruby frameworks
36
+
37
+ * {Ruby}[http://ruby-lang.org/] - the programming language of Rack and \Unicorn
38
+
39
+ * {nginx}[http://nginx.org/] - the reverse proxy for use with \Unicorn
40
+
41
+ * {kgio}[http://bogomips.org/kgio/] - the I/O library written for \Unicorn
42
+
43
+ === Derivatives
44
+
45
+ * {Green Unicorn}[http://gunicorn.org/] - a Python version of \Unicorn
46
+
47
+ * {Rainbows!}[http://rainbows.rubyforge.org/] - \Unicorn for sleepy
48
+ apps and slow clients.
49
+
50
+ === Prior Work
51
+
52
+ * {Mongrel}[http://mongrel.rubyforge.org/] - the awesome webserver \Unicorn is
53
+ based on
54
+
55
+ * {david}[http://bogomips.org/david.git] - a tool to explain why you need
56
+ nginx in front of \Unicorn
@@ -0,0 +1,145 @@
1
+ = The Philosophy Behind unicorn
2
+
3
+ Being a server that only runs on Unix-like platforms, unicorn is
4
+ strongly tied to the Unix philosophy of doing one thing and (hopefully)
5
+ doing it well. Despite using HTTP, unicorn is strictly a _backend_
6
+ application server for running Rack-based Ruby applications.
7
+
8
+ == Avoid Complexity
9
+
10
+ Instead of attempting to be efficient at serving slow clients, unicorn
11
+ relies on a buffering reverse proxy to efficiently deal with slow
12
+ clients.
13
+
14
+ unicorn uses an old-fashioned preforking worker model with blocking I/O.
15
+ Our processing model is the antithesis of more modern (and theoretically
16
+ more efficient) server processing models using threads or non-blocking
17
+ I/O with events.
18
+
19
+ === Threads and Events Are Hard
20
+
21
+ ...to many developers. Reasons for this is beyond the scope of this
22
+ document. unicorn avoids concurrency within each worker process so you
23
+ have fewer things to worry about when developing your application. Of
24
+ course unicorn can use multiple worker processes to utilize multiple
25
+ CPUs or spindles. Applications can still use threads internally, however.
26
+
27
+ == Slow Clients Are Problematic
28
+
29
+ Most benchmarks we've seen don't tell you this, and unicorn doesn't
30
+ care about slow clients... but <i>you</i> should.
31
+
32
+ A "slow client" can be any client outside of your datacenter. Network
33
+ traffic within a local network is always faster than traffic that
34
+ crosses outside of it. The laws of physics do not allow otherwise.
35
+
36
+ Persistent connections were introduced in HTTP/1.1 reduce latency from
37
+ connection establishment and TCP slow start. They also waste server
38
+ resources when clients are idle.
39
+
40
+ Persistent connections mean one of the unicorn worker processes
41
+ (depending on your application, it can be very memory hungry) would
42
+ spend a significant amount of its time idle keeping the connection alive
43
+ <i>and not doing anything else</i>. Being single-threaded and using
44
+ blocking I/O, a worker cannot serve other clients while keeping a
45
+ connection alive. Thus unicorn does not implement persistent
46
+ connections.
47
+
48
+ If your application responses are larger than the socket buffer or if
49
+ you're handling large requests (uploads), worker processes will also be
50
+ bottlenecked by the speed of the *client* connection. You should
51
+ not allow unicorn to serve clients outside of your local network.
52
+
53
+ == Application Concurrency != Network Concurrency
54
+
55
+ Performance is asymmetric across the different subsystems of the machine
56
+ and parts of the network. CPUs and main memory can process gigabytes of
57
+ data in a second; clients on the Internet are usually only capable of a
58
+ tiny fraction of that. unicorn deployments should avoid dealing with
59
+ slow clients directly and instead rely on a reverse proxy to shield it
60
+ from the effects of slow I/O.
61
+
62
+ == Improved Performance Through Reverse Proxying
63
+
64
+ By acting as a buffer to shield unicorn from slow I/O, a reverse proxy
65
+ will inevitably incur overhead in the form of extra data copies.
66
+ However, as I/O within a local network is fast (and faster still
67
+ with local sockets), this overhead is negligible for the vast majority
68
+ of HTTP requests and responses.
69
+
70
+ The ideal reverse proxy complements the weaknesses of unicorn.
71
+ A reverse proxy for unicorn should meet the following requirements:
72
+
73
+ 1. It should fully buffer all HTTP requests (and large responses).
74
+ Each request should be "corked" in the reverse proxy and sent
75
+ as fast as possible to the backend unicorn processes. This is
76
+ the most important feature to look for when choosing a
77
+ reverse proxy for unicorn.
78
+
79
+ 2. It should spend minimal time in userspace. Network (and disk) I/O
80
+ are system-level tasks and usually managed by the kernel.
81
+ This may change if userspace TCP stacks become more popular in the
82
+ future; but the reverse proxy should not waste time with
83
+ application-level logic. These concerns should be separated
84
+
85
+ 3. It should avoid context switches and CPU scheduling overhead.
86
+ In many (most?) cases, network devices and their interrupts are
87
+ only be handled by one CPU at a time. It should avoid contention
88
+ within the system by serializing all network I/O into one (or few)
89
+ userspace processes. Network I/O is not a CPU-intensive task and
90
+ it is not helpful to use multiple CPU cores (at least not for GigE).
91
+
92
+ 4. It should efficiently manage persistent connections (and
93
+ pipelining) to slow clients. If you care to serve slow clients
94
+ outside your network, then these features of HTTP/1.1 will help.
95
+
96
+ 5. It should (optionally) serve static files. If you have static
97
+ files on your site (especially large ones), they are far more
98
+ efficiently served with as few data copies as possible (e.g. with
99
+ sendfile() to completely avoid copying the data to userspace).
100
+
101
+ nginx is the only (Free) solution we know of that meets the above
102
+ requirements.
103
+
104
+ Indeed, the folks behind unicorn have deployed nginx as a reverse-proxy not
105
+ only for Ruby applications, but also for production applications running
106
+ Apache/mod_perl, Apache/mod_php and Apache Tomcat. In every single
107
+ case, performance improved because application servers were able to use
108
+ backend resources more efficiently and spend less time waiting on slow
109
+ I/O.
110
+
111
+ == Worse Is Better
112
+
113
+ Requirements and scope for applications change frequently and
114
+ drastically. Thus languages like Ruby and frameworks like Rails were
115
+ built to give developers fewer things to worry about in the face of
116
+ rapid change.
117
+
118
+ On the other hand, stable protocols which host your applications (HTTP
119
+ and TCP) only change rarely. This is why we recommend you NOT tie your
120
+ rapidly-changing application logic directly into the processes that deal
121
+ with the stable outside world. Instead, use HTTP as a common RPC
122
+ protocol to communicate between your frontend and backend.
123
+
124
+ In short: separate your concerns.
125
+
126
+ Of course a theoretical "perfect" solution would combine the pieces
127
+ and _maybe_ give you better performance at the end of the day, but
128
+ that is not the Unix way.
129
+
130
+ == Just Worse in Some Cases
131
+
132
+ unicorn is not suited for all applications. unicorn is optimized for
133
+ applications that are CPU/memory/disk intensive and spend little time
134
+ waiting on external resources (e.g. a database server or external API).
135
+
136
+ unicorn is highly inefficient for Comet/reverse-HTTP/push applications
137
+ where the HTTP connection spends a large amount of time idle.
138
+ Nevertheless, the ease of troubleshooting, debugging, and management of
139
+ unicorn may still outweigh the drawbacks for these applications.
140
+
141
+ The {Rainbows!}[http://rainbows.rubyforge.org/] aims to fill the gap for
142
+ odd corner cases where the nginx + unicorn combination is not enough.
143
+ While Rainbows! management/administration is largely identical to
144
+ unicorn, Rainbows! is far more ambitious and has seen little real-world
145
+ usage.
data/README ADDED
@@ -0,0 +1,154 @@
1
+ = Unicorn: Rack HTTP server for fast clients and Unix
2
+
3
+ \This is a fork of Unicorn designed to run on Heroku. Heroku and Unicorn
4
+ disagree on signal handling, so I've swapped Unicorn's handling of
5
+ SIGINT/SIGTERM and SIGQUIT. Now, Unicorn can shut down gracefully on
6
+ Heroku.
7
+
8
+ Unicorn is an HTTP server for Rack applications designed to only serve
9
+ fast clients on low-latency, high-bandwidth connections and take
10
+ advantage of features in Unix/Unix-like kernels. Slow clients should
11
+ only be served by placing a reverse proxy capable of fully buffering
12
+ both the the request and response in between \Unicorn and slow clients.
13
+
14
+ == Features
15
+
16
+ * Designed for Rack, Unix, fast clients, and ease-of-debugging. We
17
+ cut out everything that is better supported by the operating system,
18
+ {nginx}[http://nginx.net/] or {Rack}[http://rack.rubyforge.org/].
19
+
20
+ * Compatible with both Ruby 1.8 and 1.9. Rubinius support is in-progress.
21
+
22
+ * Process management: \Unicorn will reap and restart workers that
23
+ die from broken apps. There is no need to manage multiple processes
24
+ or ports yourself. \Unicorn can spawn and manage any number of
25
+ worker processes you choose to scale to your backend.
26
+
27
+ * Load balancing is done entirely by the operating system kernel.
28
+ Requests never pile up behind a busy worker process.
29
+
30
+ * Does not care if your application is thread-safe or not, workers
31
+ all run within their own isolated address space and only serve one
32
+ client at a time for maximum robustness.
33
+
34
+ * Supports all Rack applications, along with pre-Rack versions of
35
+ Ruby on Rails via a Rack wrapper.
36
+
37
+ * Builtin reopening of all log files in your application via
38
+ USR1 signal. This allows logrotate to rotate files atomically and
39
+ quickly via rename instead of the racy and slow copytruncate method.
40
+ \Unicorn also takes steps to ensure multi-line log entries from one
41
+ request all stay within the same file.
42
+
43
+ * nginx-style binary upgrades without losing connections.
44
+ You can upgrade \Unicorn, your entire application, libraries
45
+ and even your Ruby interpreter without dropping clients.
46
+
47
+ * before_fork and after_fork hooks in case your application
48
+ has special needs when dealing with forked processes. These
49
+ should not be needed when the "preload_app" directive is
50
+ false (the default).
51
+
52
+ * Can be used with copy-on-write-friendly memory management
53
+ to save memory (by setting "preload_app" to true).
54
+
55
+ * Able to listen on multiple interfaces including UNIX sockets,
56
+ each worker process can also bind to a private port via the
57
+ after_fork hook for easy debugging.
58
+
59
+ * Simple and easy Ruby DSL for configuration.
60
+
61
+ * Decodes chunked transfers on-the-fly, thus allowing upload progress
62
+ notification to be implemented as well as being able to tunnel
63
+ arbitrary stream-based protocols over HTTP.
64
+
65
+ == License
66
+
67
+ \Unicorn is copyright 2009 by all contributors (see logs in git).
68
+ It is based on Mongrel 1.1.5 and carries the same license.
69
+
70
+ Mongrel is copyright 2007 Zed A. Shaw and contributors. It is
71
+ tri-licensed under (your choice) of the GPLv3, GPLv2 or Ruby-specific
72
+ terms. See the included LICENSE file for details.
73
+
74
+ \Unicorn is 100% Free Software.
75
+
76
+ == Install
77
+
78
+ The library consists of a C extension so you'll need a C compiler
79
+ and Ruby development libraries/headers.
80
+
81
+ You may download the tarball from the Mongrel project page on Rubyforge
82
+ and run setup.rb after unpacking it:
83
+
84
+ http://rubyforge.org/frs/?group_id=1306
85
+
86
+ You may also install it via RubyGems on RubyGems.org:
87
+
88
+ gem install unicorn
89
+
90
+ You can get the latest source via git from the following locations
91
+ (these versions may not be stable):
92
+
93
+ git://bogomips.org/unicorn.git
94
+ git://repo.or.cz/unicorn.git (mirror)
95
+
96
+ You may browse the code from the web and download the latest snapshot
97
+ tarballs here:
98
+
99
+ * http://bogomips.org/unicorn.git (cgit)
100
+ * http://repo.or.cz/w/unicorn.git (gitweb)
101
+
102
+ See the HACKING guide on how to contribute and build prerelease gems
103
+ from git.
104
+
105
+ == Usage
106
+
107
+ === non-Rails Rack applications
108
+
109
+ In APP_ROOT, run:
110
+
111
+ unicorn
112
+
113
+ === for Rails applications (should work for all 1.2 or later versions)
114
+
115
+ In RAILS_ROOT, run:
116
+
117
+ unicorn_rails
118
+
119
+ \Unicorn will bind to all interfaces on TCP port 8080 by default.
120
+ You may use the +--listen/-l+ switch to bind to a different
121
+ address:port or a UNIX socket.
122
+
123
+ === Configuration File(s)
124
+
125
+ \Unicorn will look for the config.ru file used by rackup in APP_ROOT.
126
+
127
+ For deployments, it can use a config file for \Unicorn-specific options
128
+ specified by the +--config-file/-c+ command-line switch. See
129
+ Unicorn::Configurator for the syntax of the \Unicorn-specific options.
130
+ The default settings are designed for maximum out-of-the-box
131
+ compatibility with existing applications.
132
+
133
+ Most command-line options for other Rack applications (above) are also
134
+ supported. Run `unicorn -h` or `unicorn_rails -h` to see command-line
135
+ options.
136
+
137
+ == Disclaimer
138
+
139
+ There is NO WARRANTY whatsoever if anything goes wrong, but
140
+ {let us know}[link:ISSUES.html] and we'll try our best to fix it.
141
+
142
+ \Unicorn is designed to only serve fast clients either on the local host
143
+ or a fast LAN. See the PHILOSOPHY and DESIGN documents for more details
144
+ regarding this.
145
+
146
+ == Contact
147
+
148
+ All feedback (bug reports, user/development dicussion, patches, pull
149
+ requests) go to the mailing list/newsgroup. See the ISSUES document for
150
+ information on the {mailing list}[mailto:mongrel-unicorn@rubyforge.org].
151
+
152
+ For the latest on \Unicorn releases, you may also finger us at
153
+ unicorn@bogomips.org or check our NEWS page (and subscribe to our Atom
154
+ feed).