unicorn-lb-patch 4.3.1.11.g21b8.dirty

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. data/.CHANGELOG.old +25 -0
  2. data/.document +29 -0
  3. data/.gitignore +25 -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 +149 -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 +755 -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/listener_names.ru +4 -0
  87. data/t/my-tap-lib.sh +201 -0
  88. data/t/oob_gc.ru +21 -0
  89. data/t/oob_gc_path.ru +21 -0
  90. data/t/pid.ru +3 -0
  91. data/t/preread_input.ru +17 -0
  92. data/t/rack-input-tests.ru +21 -0
  93. data/t/rails3-app/.gitignore +4 -0
  94. data/t/rails3-app/Gemfile +26 -0
  95. data/t/rails3-app/Rakefile +10 -0
  96. data/t/rails3-app/app/controllers/application_controller.rb +4 -0
  97. data/t/rails3-app/app/helpers/application_helper.rb +2 -0
  98. data/t/rails3-app/app/views/layouts/application.html.erb +14 -0
  99. data/t/rails3-app/config.ru +4 -0
  100. data/t/rails3-app/config/application.rb +46 -0
  101. data/t/rails3-app/config/boot.rb +6 -0
  102. data/t/rails3-app/config/database.yml +22 -0
  103. data/t/rails3-app/config/environment.rb +5 -0
  104. data/t/rails3-app/config/environments/development.rb +19 -0
  105. data/t/rails3-app/config/environments/production.rb +42 -0
  106. data/t/rails3-app/config/environments/test.rb +32 -0
  107. data/t/rails3-app/config/initializers/backtrace_silencers.rb +7 -0
  108. data/t/rails3-app/config/initializers/inflections.rb +10 -0
  109. data/t/rails3-app/config/initializers/mime_types.rb +5 -0
  110. data/t/rails3-app/config/initializers/secret_token.rb +7 -0
  111. data/t/rails3-app/config/initializers/session_store.rb +8 -0
  112. data/t/rails3-app/config/locales/en.yml +5 -0
  113. data/t/rails3-app/config/routes.rb +58 -0
  114. data/t/rails3-app/db/seeds.rb +7 -0
  115. data/t/rails3-app/doc/README_FOR_APP +2 -0
  116. data/t/rails3-app/lib/tasks/.gitkeep +0 -0
  117. data/t/rails3-app/public/404.html +1 -0
  118. data/t/rails3-app/public/500.html +1 -0
  119. data/t/rails3-app/public/x.txt +1 -0
  120. data/t/rails3-app/script/rails +9 -0
  121. data/t/rails3-app/test/performance/browsing_test.rb +9 -0
  122. data/t/rails3-app/test/test_helper.rb +13 -0
  123. data/t/rails3-app/vendor/plugins/.gitkeep +0 -0
  124. data/t/sslgen.sh +71 -0
  125. data/t/t0000-http-basic.sh +50 -0
  126. data/t/t0001-reload-bad-config.sh +53 -0
  127. data/t/t0002-config-conflict.sh +49 -0
  128. data/t/t0002-parser-error.sh +94 -0
  129. data/t/t0003-working_directory.sh +51 -0
  130. data/t/t0004-heartbeat-timeout.sh +69 -0
  131. data/t/t0004-working_directory_broken.sh +24 -0
  132. data/t/t0005-working_directory_app.rb.sh +37 -0
  133. data/t/t0006-reopen-logs.sh +83 -0
  134. data/t/t0006.ru +13 -0
  135. data/t/t0007-working_directory_no_embed_cli.sh +44 -0
  136. data/t/t0008-back_out_of_upgrade.sh +110 -0
  137. data/t/t0009-broken-app.sh +56 -0
  138. data/t/t0009-winch_ttin.sh +59 -0
  139. data/t/t0010-reap-logging.sh +55 -0
  140. data/t/t0011-active-unix-socket.sh +79 -0
  141. data/t/t0012-reload-empty-config.sh +85 -0
  142. data/t/t0013-rewindable-input-false.sh +24 -0
  143. data/t/t0013.ru +12 -0
  144. data/t/t0014-rewindable-input-true.sh +24 -0
  145. data/t/t0014.ru +12 -0
  146. data/t/t0015-configurator-internals.sh +25 -0
  147. data/t/t0016-trust-x-forwarded-false.sh +30 -0
  148. data/t/t0017-trust-x-forwarded-true.sh +30 -0
  149. data/t/t0018-write-on-close.sh +23 -0
  150. data/t/t0019-max_header_len.sh +49 -0
  151. data/t/t0020-at_exit-handler.sh +49 -0
  152. data/t/t0021-process_detach.sh +29 -0
  153. data/t/t0022-listener-names-preload_app.sh +32 -0
  154. data/t/t0100-rack-input-tests.sh +124 -0
  155. data/t/t0116-client_body_buffer_size.sh +80 -0
  156. data/t/t0116.ru +16 -0
  157. data/t/t0300-rails3-basic.sh +28 -0
  158. data/t/t0301-rails3-missing-config-ru.sh +33 -0
  159. data/t/t0302-rails3-alt-working_directory.sh +32 -0
  160. data/t/t0303-rails3-alt-working_directory_config.ru.sh +56 -0
  161. data/t/t0304-rails3-alt-working_directory_no_embed_cli.sh +52 -0
  162. data/t/t0600-https-server-basic.sh +48 -0
  163. data/t/t9000-preread-input.sh +48 -0
  164. data/t/t9001-oob_gc.sh +47 -0
  165. data/t/t9002-oob_gc-path.sh +75 -0
  166. data/t/test-lib.sh +113 -0
  167. data/t/test-rails3.sh +27 -0
  168. data/t/write-on-close.ru +11 -0
  169. data/test/aggregate.rb +15 -0
  170. data/test/benchmark/README +50 -0
  171. data/test/benchmark/dd.ru +18 -0
  172. data/test/benchmark/stack.ru +8 -0
  173. data/test/exec/README +5 -0
  174. data/test/exec/test_exec.rb +1055 -0
  175. data/test/rails/app-1.2.3/.gitignore +2 -0
  176. data/test/rails/app-1.2.3/Rakefile +7 -0
  177. data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
  178. data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
  179. data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
  180. data/test/rails/app-1.2.3/config/boot.rb +11 -0
  181. data/test/rails/app-1.2.3/config/database.yml +12 -0
  182. data/test/rails/app-1.2.3/config/environment.rb +13 -0
  183. data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
  184. data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
  185. data/test/rails/app-1.2.3/config/routes.rb +6 -0
  186. data/test/rails/app-1.2.3/db/.gitignore +0 -0
  187. data/test/rails/app-1.2.3/public/404.html +1 -0
  188. data/test/rails/app-1.2.3/public/500.html +1 -0
  189. data/test/rails/app-2.0.2/.gitignore +2 -0
  190. data/test/rails/app-2.0.2/Rakefile +7 -0
  191. data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
  192. data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
  193. data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
  194. data/test/rails/app-2.0.2/config/boot.rb +11 -0
  195. data/test/rails/app-2.0.2/config/database.yml +12 -0
  196. data/test/rails/app-2.0.2/config/environment.rb +17 -0
  197. data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
  198. data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
  199. data/test/rails/app-2.0.2/config/routes.rb +6 -0
  200. data/test/rails/app-2.0.2/db/.gitignore +0 -0
  201. data/test/rails/app-2.0.2/public/404.html +1 -0
  202. data/test/rails/app-2.0.2/public/500.html +1 -0
  203. data/test/rails/app-2.1.2/.gitignore +2 -0
  204. data/test/rails/app-2.1.2/Rakefile +7 -0
  205. data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
  206. data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
  207. data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
  208. data/test/rails/app-2.1.2/config/boot.rb +111 -0
  209. data/test/rails/app-2.1.2/config/database.yml +12 -0
  210. data/test/rails/app-2.1.2/config/environment.rb +17 -0
  211. data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
  212. data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
  213. data/test/rails/app-2.1.2/config/routes.rb +6 -0
  214. data/test/rails/app-2.1.2/db/.gitignore +0 -0
  215. data/test/rails/app-2.1.2/public/404.html +1 -0
  216. data/test/rails/app-2.1.2/public/500.html +1 -0
  217. data/test/rails/app-2.2.2/.gitignore +2 -0
  218. data/test/rails/app-2.2.2/Rakefile +7 -0
  219. data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
  220. data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
  221. data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
  222. data/test/rails/app-2.2.2/config/boot.rb +111 -0
  223. data/test/rails/app-2.2.2/config/database.yml +12 -0
  224. data/test/rails/app-2.2.2/config/environment.rb +17 -0
  225. data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
  226. data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
  227. data/test/rails/app-2.2.2/config/routes.rb +6 -0
  228. data/test/rails/app-2.2.2/db/.gitignore +0 -0
  229. data/test/rails/app-2.2.2/public/404.html +1 -0
  230. data/test/rails/app-2.2.2/public/500.html +1 -0
  231. data/test/rails/test_rails.rb +287 -0
  232. data/test/test_helper.rb +300 -0
  233. data/test/unit/test_configurator.rb +158 -0
  234. data/test/unit/test_droplet.rb +28 -0
  235. data/test/unit/test_http_parser.rb +860 -0
  236. data/test/unit/test_http_parser_ng.rb +716 -0
  237. data/test/unit/test_http_parser_xftrust.rb +38 -0
  238. data/test/unit/test_request.rb +197 -0
  239. data/test/unit/test_response.rb +99 -0
  240. data/test/unit/test_server.rb +289 -0
  241. data/test/unit/test_signals.rb +207 -0
  242. data/test/unit/test_sni_hostnames.rb +47 -0
  243. data/test/unit/test_socket_helper.rb +192 -0
  244. data/test/unit/test_stream_input.rb +204 -0
  245. data/test/unit/test_tee_input.rb +296 -0
  246. data/test/unit/test_upload.rb +306 -0
  247. data/test/unit/test_util.rb +100 -0
  248. data/unicorn-lb-patch.gemspec +27 -0
  249. metadata +561 -0
data/DESIGN ADDED
@@ -0,0 +1,97 @@
1
+ == Design
2
+
3
+ * Simplicity: Unicorn is a traditional UNIX prefork web server.
4
+ No threads are used at all, this makes applications easier to debug
5
+ and fix. When your application goes awry, a BOFH can just
6
+ "kill -9" the runaway worker process without worrying about tearing
7
+ all clients down, just one. Only UNIX-like systems supporting
8
+ fork() and file descriptor inheritance are supported.
9
+
10
+ * The Ragel+C HTTP parser is taken from Mongrel. This is the
11
+ only non-Ruby part and there are no plans to add any more
12
+ non-Ruby components.
13
+
14
+ * All HTTP parsing and I/O is done much like Mongrel:
15
+ 1. read/parse HTTP request headers in full
16
+ 2. call Rack application
17
+ 3. write HTTP response back to the client
18
+
19
+ * Like Mongrel, neither keepalive nor pipelining are supported.
20
+ These aren't needed since Unicorn is only designed to serve
21
+ fast, low-latency clients directly. Do one thing, do it well;
22
+ let nginx handle slow clients.
23
+
24
+ * Configuration is purely in Ruby and eval(). Ruby is less
25
+ ambiguous than YAML and lets lambdas for
26
+ before_fork/after_fork/before_exec hooks be defined inline. An
27
+ optional, separate config_file may be used to modify supported
28
+ configuration changes (and also gives you plenty of rope if you RTFS
29
+ :>)
30
+
31
+ * One master process spawns and reaps worker processes. The
32
+ Rack application itself is called only within the worker process (but
33
+ can be loaded within the master). A copy-on-write friendly garbage
34
+ collector like the one found in Ruby 2.0.0dev or Ruby Enterprise Edition
35
+ can be used to minimize memory usage along with the "preload_app true"
36
+ directive (see Unicorn::Configurator).
37
+
38
+ * The number of worker processes should be scaled to the number of
39
+ CPUs, memory or even spindles you have. If you have an existing
40
+ Mongrel cluster on a single-threaded app, using the same amount of
41
+ processes should work. Let a full-HTTP-request-buffering reverse
42
+ proxy like nginx manage concurrency to thousands of slow clients for
43
+ you. Unicorn scaling should only be concerned about limits of your
44
+ backend system(s).
45
+
46
+ * Load balancing between worker processes is done by the OS kernel.
47
+ All workers share a common set of listener sockets and does
48
+ non-blocking accept() on them. The kernel will decide which worker
49
+ process to give a socket to and workers will sleep if there is
50
+ nothing to accept().
51
+
52
+ * Since non-blocking accept() is used, there can be a thundering
53
+ herd when an occasional client connects when application
54
+ *is not busy*. The thundering herd problem should not affect
55
+ applications that are running all the time since worker processes
56
+ will only select()/accept() outside of the application dispatch.
57
+
58
+ * Additionally, thundering herds are much smaller than with
59
+ configurations using existing prefork servers. Process counts should
60
+ only be scaled to backend resources, _never_ to the number of expected
61
+ clients like is typical with blocking prefork servers. So while we've
62
+ seen instances of popular prefork servers configured to run many
63
+ hundreds of worker processes, Unicorn deployments are typically only
64
+ 2-4 processes per-core.
65
+
66
+ * On-demand scaling of worker processes never happens automatically.
67
+ Again, Unicorn is concerned about scaling to backend limits and should
68
+ never configured in a fashion where it could be waiting on slow
69
+ clients. For extremely rare circumstances, we provide TTIN and TTOU
70
+ signal handlers to increment/decrement your process counts without
71
+ reloading. Think of it as driving a car with manual transmission:
72
+ you have a lot more control if you know what you're doing.
73
+
74
+ * Blocking I/O is used for clients. This allows a simpler code path
75
+ to be followed within the Ruby interpreter and fewer syscalls.
76
+ Applications that use threads continue to work if Unicorn
77
+ is only serving LAN or localhost clients.
78
+
79
+ * SIGKILL is used to terminate the timed-out workers from misbehaving apps
80
+ as reliably as possible on a UNIX system. The default timeout is a
81
+ generous 60 seconds (same default as in Mongrel).
82
+
83
+ * The poor performance of select() on large FD sets is avoided
84
+ as few file descriptors are used in each worker.
85
+ There should be no gain from moving to highly scalable but
86
+ unportable event notification solutions for watching few
87
+ file descriptors.
88
+
89
+ * If the master process dies unexpectedly for any reason,
90
+ workers will notice within :timeout/2 seconds and follow
91
+ the master to its death.
92
+
93
+ * There is never any explicit real-time dependency or communication
94
+ between the worker processes nor to the master process.
95
+ Synchronization is handled entirely by the OS kernel and shared
96
+ resources are never accessed by the worker when it is servicing
97
+ a client.
@@ -0,0 +1,5 @@
1
+ *.1
2
+ *.5
3
+ *.7
4
+ *.gz
5
+ *.html
@@ -0,0 +1,30 @@
1
+ all::
2
+
3
+ PANDOC = pandoc
4
+ PANDOC_OPTS = -f markdown --email-obfuscation=none
5
+ pandoc = $(PANDOC) $(PANDOC_OPTS)
6
+ pandoc_html = $(pandoc) --toc -t html --no-wrap
7
+
8
+ man1 := $(addsuffix .1,unicorn unicorn_rails)
9
+ html1 := $(addsuffix .html,$(man1))
10
+
11
+ all:: html man
12
+
13
+ html: $(html1)
14
+ man: $(man1)
15
+
16
+ install-html: html
17
+ mkdir -p ../doc/man1
18
+ install -m 644 $(html1) ../doc/man1
19
+
20
+ install-man: man
21
+ mkdir -p ../man/man1
22
+ install -m 644 $(man1) ../man/man1
23
+
24
+ %.1: %.1.txt
25
+ $(pandoc) -s -t man < $< > $@+ && mv $@+ $@
26
+ %.1.html: %.1.txt
27
+ $(pandoc_html) < $< > $@+ && mv $@+ $@
28
+
29
+ clean::
30
+ $(RM) $(man1) $(html1)
@@ -0,0 +1,174 @@
1
+ % UNICORN(1) Unicorn User Manual
2
+ % The Unicorn Community <mongrel-unicorn@rubyforge.org>
3
+ % September 15, 2009
4
+
5
+ # NAME
6
+
7
+ unicorn - a rackup-like command to launch the Unicorn HTTP server
8
+
9
+ # SYNOPSIS
10
+
11
+ unicorn [-c CONFIG_FILE] [-E RACK_ENV] [-D] [RACKUP_FILE]
12
+
13
+ # DESCRIPTION
14
+
15
+ A rackup(1)-like command to launch Rack applications using Unicorn.
16
+ It is expected to be started in your application root (APP_ROOT),
17
+ but the "working_directory" directive may be used in the CONFIG_FILE.
18
+
19
+ While unicorn takes a myriad of command-line options for
20
+ compatibility with ruby(1) and rackup(1), it is recommended to stick
21
+ to the few command-line options specified in the SYNOPSIS and use
22
+ the CONFIG_FILE as much as possible.
23
+
24
+ # RACKUP FILE
25
+
26
+ This defaults to \"config.ru\" in APP_ROOT. It should be the same
27
+ file used by rackup(1) and other Rack launchers, it uses the
28
+ *Rack::Builder* DSL.
29
+
30
+ Embedded command-line options are mostly parsed for compatibility
31
+ with rackup(1) but strongly discouraged.
32
+
33
+ # UNICORN OPTIONS
34
+ -c, \--config-file CONFIG_FILE
35
+ : Path to the Unicorn-specific config file. The config file is
36
+ implemented as a Ruby DSL, so Ruby code may executed.
37
+ See the RDoc/ri for the *Unicorn::Configurator* class for the full
38
+ list of directives available from the DSL.
39
+ Using an absolute path for for CONFIG_FILE is recommended as it
40
+ makes multiple instances of Unicorn easily distinguishable when
41
+ viewing ps(1) output.
42
+
43
+ -D, \--daemonize
44
+ : Run daemonized in the background. The process is detached from
45
+ the controlling terminal and stdin is redirected to "/dev/null".
46
+ Unlike many common UNIX daemons, we do not chdir to \"/\"
47
+ upon daemonization to allow more control over the startup/upgrade
48
+ process.
49
+ Unless specified in the CONFIG_FILE, stderr and stdout will
50
+ also be redirected to "/dev/null".
51
+
52
+ -E, \--env RACK_ENV
53
+ : Run under the given RACK_ENV. See the RACK ENVIRONMENT section
54
+ for more details.
55
+
56
+ -l, \--listen ADDRESS
57
+ : Listens on a given ADDRESS. ADDRESS may be in the form of
58
+ HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
59
+ and PATH is meant to be a path to a UNIX domain socket.
60
+ Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080)
61
+ For production deployments, specifying the "listen" directive in
62
+ CONFIG_FILE is recommended as it allows fine-tuning of socket
63
+ options.
64
+
65
+ # RACKUP COMPATIBILITY OPTIONS
66
+ -o, \--host HOST
67
+ : Listen on a TCP socket belonging to HOST, default is
68
+ "0.0.0.0" (all addresses).
69
+ If specified multiple times on the command-line, only the
70
+ last-specified value takes effect.
71
+ This option only exists for compatibility with the rackup(1) command,
72
+ use of "-l"/"\--listen" switch is recommended instead.
73
+
74
+ -p, \--port PORT
75
+ : Listen on the specified TCP PORT, default is 8080.
76
+ If specified multiple times on the command-line, only the last-specified
77
+ value takes effect.
78
+ This option only exists for compatibility with the rackup(1) command,
79
+ use of "-l"/"\--listen" switch is recommended instead.
80
+
81
+ -s, \--server SERVER
82
+ : No-op, this exists only for compatibility with rackup(1).
83
+
84
+ # RUBY OPTIONS
85
+ -e, \--eval LINE
86
+ : Evaluate a LINE of Ruby code. This evaluation happens
87
+ immediately as the command-line is being parsed.
88
+
89
+ -d, \--debug
90
+ : Turn on debug mode, the $DEBUG variable is set to true.
91
+
92
+ -w, \--warn
93
+ : Turn on verbose warnings, the $VERBOSE variable is set to true.
94
+
95
+ -I, \--include PATH
96
+ : specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
97
+ The \':\' character may be used to delimit multiple directories.
98
+ This directive may be used more than once. Modifications to
99
+ $LOAD_PATH take place immediately and in the order they were
100
+ specified on the command-line.
101
+
102
+ -r, \--require LIBRARY
103
+ : require a specified LIBRARY before executing the application. The
104
+ \"require\" statement will be executed immediately and in the order
105
+ they were specified on the command-line.
106
+
107
+ # SIGNALS
108
+
109
+ The following UNIX signals may be sent to the master process:
110
+
111
+ * HUP - reload config file, app, and gracefully restart all workers
112
+ * INT/TERM - quick shutdown, kills all workers immediately
113
+ * QUIT - graceful shutdown, waits for workers to finish their
114
+ current request before finishing.
115
+ * USR1 - reopen all logs owned by the master and all workers
116
+ See Unicorn::Util.reopen_logs for what is considered a log.
117
+ * USR2 - reexecute the running binary. A separate QUIT
118
+ should be sent to the original process once the child is verified to
119
+ be up and running.
120
+ * WINCH - gracefully stops workers but keep the master running.
121
+ This will only work for daemonized processes.
122
+ * TTIN - increment the number of worker processes by one
123
+ * TTOU - decrement the number of worker processes by one
124
+
125
+ See the [SIGNALS][4] document for full description of all signals
126
+ used by Unicorn.
127
+
128
+ # RACK ENVIRONMENT
129
+
130
+ Accepted values of RACK_ENV and the middleware they automatically load
131
+ (outside of RACKUP_FILE) are exactly as those in rackup(1):
132
+
133
+ * development - loads Rack::CommonLogger, Rack::ShowExceptions, and
134
+ Rack::Lint middleware
135
+ * deployment - loads Rack::CommonLogger middleware
136
+ * none - loads no middleware at all, relying
137
+ entirely on RACKUP_FILE
138
+
139
+ All unrecognized values for RACK_ENV are assumed to be
140
+ "none". Production deployments are strongly encouraged to use
141
+ "deployment" or "none" for maximum performance.
142
+
143
+ As of Unicorn 0.94.0, RACK_ENV is exported as a process-wide environment
144
+ variable as well. While not current a part of the Rack specification as
145
+ of Rack 1.0.1, this has become a de facto standard in the Rack world.
146
+
147
+ Note that the Rack::ContentLength and Rack::Chunked middlewares
148
+ are never loaded by default. If needed, they should be
149
+ individually specified in the RACKUP_FILE, some frameworks do
150
+ not require them.
151
+
152
+ # ENVIRONMENT VARIABLES
153
+
154
+ The RACK_ENV variable is set by the aforementioned \-E switch.
155
+ All application or library-specific environment variables (e.g. TMPDIR)
156
+ may always be set in the Unicorn CONFIG_FILE in addition to the spawning
157
+ shell. When transparently upgrading Unicorn, all environment variables
158
+ set in the old master process are inherited by the new master process.
159
+ Unicorn only uses (and will overwrite) the UNICORN_FD environment
160
+ variable internally when doing transparent upgrades.
161
+
162
+ # SEE ALSO
163
+
164
+ * unicorn_rails(1)
165
+ * *Rack::Builder* ri/RDoc
166
+ * *Unicorn::Configurator* ri/RDoc
167
+ * [Unicorn RDoc][1]
168
+ * [Rack RDoc][2]
169
+ * [Rackup HowTo][3]
170
+
171
+ [1]: http://unicorn.bogomips.org/
172
+ [2]: http://rack.rubyforge.org/doc/
173
+ [3]: http://wiki.github.com/rack/rack/tutorial-rackup-howto
174
+ [4]: http://unicorn.bogomips.org/SIGNALS.html
@@ -0,0 +1,175 @@
1
+ % UNICORN_RAILS(1) Unicorn User Manual
2
+ % The Unicorn Community <mongrel-unicorn@rubyforge.org>
3
+ % September 17, 2009
4
+
5
+ # NAME
6
+
7
+ unicorn_rails - a script/server-like command to launch the Unicorn HTTP server
8
+
9
+ # SYNOPSIS
10
+
11
+ unicorn_rails [-c CONFIG_FILE] [-E RAILS_ENV] [-D] [RACKUP_FILE]
12
+
13
+ # DESCRIPTION
14
+
15
+ A rackup(1)-like command to launch Rails applications using Unicorn. It
16
+ is expected to be started in your Rails application root (RAILS_ROOT),
17
+ but the "working_directory" directive may be used in the CONFIG_FILE.
18
+
19
+ It is designed to help Rails 1.x and 2.y users transition to Rack, but
20
+ it is NOT needed for Rails 3 applications. Rails 3 users are encouraged
21
+ to use unicorn(1) instead of unicorn_rails(1). Users of Rails 1.x/2.y
22
+ may also use unicorn(1) instead of unicorn_rails(1).
23
+
24
+ The outward interface resembles rackup(1), the internals and default
25
+ middleware loading is designed like the `script/server` command
26
+ distributed with Rails.
27
+
28
+ While Unicorn takes a myriad of command-line options for compatibility
29
+ with ruby(1) and rackup(1), it is recommended to stick to the few
30
+ command-line options specified in the SYNOPSIS and use the CONFIG_FILE
31
+ as much as possible.
32
+
33
+ # UNICORN OPTIONS
34
+ -c, \--config-file CONFIG_FILE
35
+ : Path to the Unicorn-specific config file. The config file is
36
+ implemented as a Ruby DSL, so Ruby code may executed.
37
+ See the RDoc/ri for the *Unicorn::Configurator* class for the full
38
+ list of directives available from the DSL.
39
+ Using an absolute path for for CONFIG_FILE is recommended as it
40
+ makes multiple instances of Unicorn easily distinguishable when
41
+ viewing ps(1) output.
42
+
43
+ -D, \--daemonize
44
+ : Run daemonized in the background. The process is detached from
45
+ the controlling terminal and stdin is redirected to "/dev/null".
46
+ Unlike many common UNIX daemons, we do not chdir to \"/\"
47
+ upon daemonization to allow more control over the startup/upgrade
48
+ process.
49
+ Unless specified in the CONFIG_FILE, stderr and stdout will
50
+ also be redirected to "/dev/null".
51
+ Daemonization will _skip_ loading of the *Rails::Rack::LogTailer*
52
+ middleware under Rails \>\= 2.3.x.
53
+ By default, unicorn\_rails(1) will create a PID file in
54
+ _\"RAILS\_ROOT/tmp/pids/unicorn.pid\"_. You may override this
55
+ by specifying the "pid" directive to override this Unicorn config file.
56
+
57
+ -E, \--env RAILS_ENV
58
+ : Run under the given RAILS_ENV. This sets the RAILS_ENV environment
59
+ variable. Acceptable values are exactly those you expect in your Rails
60
+ application, typically "development" or "production".
61
+
62
+ -l, \--listen ADDRESS
63
+ : Listens on a given ADDRESS. ADDRESS may be in the form of
64
+ HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
65
+ and PATH is meant to be a path to a UNIX domain socket.
66
+ Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080).
67
+ For production deployments, specifying the "listen" directive in
68
+ CONFIG_FILE is recommended as it allows fine-tuning of socket
69
+ options.
70
+
71
+ # RACKUP COMPATIBILITY OPTIONS
72
+ -o, \--host HOST
73
+ : Listen on a TCP socket belonging to HOST, default is
74
+ "0.0.0.0" (all addresses).
75
+ If specified multiple times on the command-line, only the
76
+ last-specified value takes effect.
77
+ This option only exists for compatibility with the rackup(1) command,
78
+ use of "-l"/"\--listen" switch is recommended instead.
79
+
80
+ -p, \--port PORT
81
+ : Listen on the specified TCP PORT, default is 8080.
82
+ If specified multiple times on the command-line, only the last-specified
83
+ value takes effect.
84
+ This option only exists for compatibility with the rackup(1) command,
85
+ use of "-l"/"\--listen" switch is recommended instead.
86
+
87
+ \--path PATH
88
+ : Mounts the Rails application at the given PATH (instead of "/").
89
+ This is equivalent to setting the RAILS_RELATIVE_URL_ROOT
90
+ environment variable. This is only supported under Rails 2.3
91
+ or later at the moment.
92
+
93
+ # RUBY OPTIONS
94
+ -e, \--eval LINE
95
+ : Evaluate a LINE of Ruby code. This evaluation happens
96
+ immediately as the command-line is being parsed.
97
+
98
+ -d, \--debug
99
+ : Turn on debug mode, the $DEBUG variable is set to true.
100
+ For Rails \>\= 2.3.x, this loads the *Rails::Rack::Debugger*
101
+ middleware.
102
+
103
+ -w, \--warn
104
+ : Turn on verbose warnings, the $VERBOSE variable is set to true.
105
+
106
+ -I, \--include PATH
107
+ : specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
108
+ The \':\' character may be used to delimit multiple directories.
109
+ This directive may be used more than once. Modifications to
110
+ $LOAD_PATH take place immediately and in the order they were
111
+ specified on the command-line.
112
+
113
+ -r, \--require LIBRARY
114
+ : require a specified LIBRARY before executing the application. The
115
+ \"require\" statement will be executed immediately and in the order
116
+ they were specified on the command-line.
117
+
118
+ # RACKUP FILE
119
+
120
+ This defaults to \"config.ru\" in RAILS_ROOT. It should be the same
121
+ file used by rackup(1) and other Rack launchers, it uses the
122
+ *Rack::Builder* DSL. Unlike many other Rack applications, RACKUP_FILE
123
+ is completely _optional_ for Rails, but may be used to disable some
124
+ of the default middleware for performance.
125
+
126
+ Embedded command-line options are mostly parsed for compatibility
127
+ with rackup(1) but strongly discouraged.
128
+
129
+ # ENVIRONMENT VARIABLES
130
+
131
+ The RAILS_ENV variable is set by the aforementioned \-E switch. The
132
+ RAILS_RELATIVE_URL_ROOT is set by the aforementioned \--path switch.
133
+ Either of these variables may also be set in the shell or the Unicorn
134
+ CONFIG_FILE. All application or library-specific environment variables
135
+ (e.g. TMPDIR, RAILS_ASSET_ID) may always be set in the Unicorn
136
+ CONFIG_FILE in addition to the spawning shell. When transparently
137
+ upgrading Unicorn, all environment variables set in the old master
138
+ process are inherited by the new master process. Unicorn only uses (and
139
+ will overwrite) the UNICORN_FD environment variable internally when
140
+ doing transparent upgrades.
141
+
142
+ # SIGNALS
143
+
144
+ The following UNIX signals may be sent to the master process:
145
+
146
+ * HUP - reload config file, app, and gracefully restart all workers
147
+ * INT/TERM - quick shutdown, kills all workers immediately
148
+ * QUIT - graceful shutdown, waits for workers to finish their
149
+ current request before finishing.
150
+ * USR1 - reopen all logs owned by the master and all workers
151
+ See Unicorn::Util.reopen_logs for what is considered a log.
152
+ * USR2 - reexecute the running binary. A separate QUIT
153
+ should be sent to the original process once the child is verified to
154
+ be up and running.
155
+ * WINCH - gracefully stops workers but keep the master running.
156
+ This will only work for daemonized processes.
157
+ * TTIN - increment the number of worker processes by one
158
+ * TTOU - decrement the number of worker processes by one
159
+
160
+ See the [SIGNALS][4] document for full description of all signals
161
+ used by Unicorn.
162
+
163
+ # SEE ALSO
164
+
165
+ * unicorn(1)
166
+ * *Rack::Builder* ri/RDoc
167
+ * *Unicorn::Configurator* ri/RDoc
168
+ * [Unicorn RDoc][1]
169
+ * [Rack RDoc][2]
170
+ * [Rackup HowTo][3]
171
+
172
+ [1]: http://unicorn.bogomips.org/
173
+ [2]: http://rack.rubyforge.org/doc/
174
+ [3]: http://wiki.github.com/rack/rack/tutorial-rackup-howto
175
+ [4]: http://unicorn.bogomips.org/SIGNALS.html