unicorn-fotopedia 0.99.1

Sign up to get free protection for your applications and to get access to all the features.
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/DESIGN ADDED
@@ -0,0 +1,105 @@
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 protocol 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 Ruby Enterprise Edition can be used to minimize memory
35
+ usage along with the "preload_app true" directive (see
36
+ 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
+ * Timeout implementation is done via fchmod(2) in each worker
80
+ on a shared file descriptor to update st_ctime on the inode.
81
+ Master process wakeups for checking on timeouts is throttled
82
+ one a second to minimize the performance impact and simplify
83
+ the code path within the worker. Neither futimes(2) nor
84
+ pwrite(2)/pread(2) are supported by base MRI, nor are they as
85
+ portable on UNIX systems as fchmod(2).
86
+
87
+ * SIGKILL is used to terminate the timed-out workers from misbehaving apps
88
+ as reliably as possible on a UNIX system. The default timeout is a
89
+ generous 60 seconds (same default as in Mongrel).
90
+
91
+ * The poor performance of select() on large FD sets is avoided
92
+ as few file descriptors are used in each worker.
93
+ There should be no gain from moving to highly scalable but
94
+ unportable event notification solutions for watching few
95
+ file descriptors.
96
+
97
+ * If the master process dies unexpectedly for any reason,
98
+ workers will notice within :timeout/2 seconds and follow
99
+ the master to its death.
100
+
101
+ * There is never any explicit real-time dependency or communication
102
+ between the worker processes nor to the master process.
103
+ Synchronization is handled entirely by the OS kernel and shared
104
+ resources are never accessed by the worker when it is servicing
105
+ 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 --sanitize-html
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,171 @@
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
+
40
+ -D, \--daemonize
41
+ : Run daemonized in the background. The process is detached from
42
+ the controlling terminal and stdin is redirected to "/dev/null".
43
+ Unlike many common UNIX daemons, we do not chdir to \"/\"
44
+ upon daemonization to allow more control over the startup/upgrade
45
+ process.
46
+ Unless specified in the CONFIG_FILE, stderr and stdout will
47
+ also be redirected to "/dev/null".
48
+
49
+ -E, \--env RACK_ENV
50
+ : Run under the given RACK_ENV. See the RACK ENVIRONMENT section
51
+ for more details.
52
+
53
+ -l, \--listen ADDRESS
54
+ : Listens on a given ADDRESS. ADDRESS may be in the form of
55
+ HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
56
+ and PATH is meant to be a path to a UNIX domain socket.
57
+ Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080)
58
+ For production deployments, specifying the "listen" directive in
59
+ CONFIG_FILE is recommended as it allows fine-tuning of socket
60
+ options.
61
+
62
+ # RACKUP COMPATIBILITY OPTIONS
63
+ -o, \--host HOST
64
+ : Listen on a TCP socket belonging to HOST, default is
65
+ "0.0.0.0" (all addresses).
66
+ If specified multiple times on the command-line, only the
67
+ last-specified value takes effect.
68
+ This option only exists for compatibility with the rackup(1) command,
69
+ use of "-l"/"\--listen" switch is recommended instead.
70
+
71
+ -p, \--port PORT
72
+ : Listen on the specified TCP PORT, default is 8080.
73
+ If specified multiple times on the command-line, only the last-specified
74
+ value takes effect.
75
+ This option only exists for compatibility with the rackup(1) command,
76
+ use of "-l"/"\--listen" switch is recommended instead.
77
+
78
+ -s, \--server SERVER
79
+ : No-op, this exists only for compatibility with rackup(1).
80
+
81
+ # RUBY OPTIONS
82
+ -e, \--eval LINE
83
+ : Evaluate a LINE of Ruby code. This evaluation happens
84
+ immediately as the command-line is being parsed.
85
+
86
+ -d, \--debug
87
+ : Turn on debug mode, the $DEBUG variable is set to true.
88
+
89
+ -w, \--warn
90
+ : Turn on verbose warnings, the $VERBOSE variable is set to true.
91
+
92
+ -I, \--include PATH
93
+ : specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
94
+ The \':\' character may be used to delimit multiple directories.
95
+ This directive may be used more than once. Modifications to
96
+ $LOAD_PATH take place immediately and in the order they were
97
+ specified on the command-line.
98
+
99
+ -r, \--require LIBRARY
100
+ : require a specified LIBRARY before executing the application. The
101
+ \"require\" statement will be executed immediately and in the order
102
+ they were specified on the command-line.
103
+
104
+ # SIGNALS
105
+
106
+ The following UNIX signals may be sent to the master process:
107
+
108
+ * HUP - reload config file, app, and gracefully restart all workers
109
+ * INT/TERM - quick shutdown, kills all workers immediately
110
+ * QUIT - graceful shutdown, waits for workers to finish their
111
+ current request before finishing.
112
+ * USR1 - reopen all logs owned by the master and all workers
113
+ See Unicorn::Util.reopen_logs for what is considered a log.
114
+ * USR2 - reexecute the running binary. A separate QUIT
115
+ should be sent to the original process once the child is verified to
116
+ be up and running.
117
+ * WINCH - gracefully stops workers but keep the master running.
118
+ This will only work for daemonized processes.
119
+ * TTIN - increment the number of worker processes by one
120
+ * TTOU - decrement the number of worker processes by one
121
+
122
+ See the [SIGNALS][4] document for full description of all signals
123
+ used by Unicorn.
124
+
125
+ # RACK ENVIRONMENT
126
+
127
+ Accepted values of RACK_ENV and the middleware they automatically load
128
+ (outside of RACKUP_FILE) are exactly as those in rackup(1):
129
+
130
+ * development - loads Rack::CommonLogger, Rack::ShowExceptions, and
131
+ Rack::Lint middleware
132
+ * deployment - loads Rack::CommonLogger middleware
133
+ * none - loads no middleware at all, relying
134
+ entirely on RACKUP_FILE
135
+
136
+ All unrecognized values for RACK_ENV are assumed to be
137
+ "none". Production deployments are strongly encouraged to use
138
+ "deployment" or "none" for maximum performance.
139
+
140
+ As of Unicorn 0.94.0, RACK_ENV is exported as a process-wide environment
141
+ variable as well. While not current a part of the Rack specification as
142
+ of Rack 1.0.1, this has become a de facto standard in the Rack world.
143
+
144
+ Note that the Rack::ContentLength and Rack::Chunked middlewares
145
+ are never loaded by default. If needed, they should be
146
+ individually specified in the RACKUP_FILE, some frameworks do
147
+ not require them.
148
+
149
+ # ENVIRONMENT VARIABLES
150
+
151
+ The RACK_ENV variable is set by the aforementioned \-E switch.
152
+ All application or library-specific environment variables (e.g. TMPDIR)
153
+ may always be set in the Unicorn CONFIG_FILE in addition to the spawning
154
+ shell. When transparently upgrading Unicorn, all environment variables
155
+ set in the old master process are inherited by the new master process.
156
+ Unicorn only uses (and will overwrite) the UNICORN_FD environment
157
+ variable internally when doing transparent upgrades.
158
+
159
+ # SEE ALSO
160
+
161
+ * unicorn_rails(1)
162
+ * *Rack::Builder* ri/RDoc
163
+ * *Unicorn::Configurator* ri/RDoc
164
+ * [Unicorn RDoc][1]
165
+ * [Rack RDoc][2]
166
+ * [Rackup HowTo][3]
167
+
168
+ [1]: http://unicorn.bogomips.org/
169
+ [2]: http://rack.rubyforge.org/doc/
170
+ [3]: http://wiki.github.com/rack/rack/tutorial-rackup-howto
171
+ [4]: http://unicorn.bogomips.org/SIGNALS.html
@@ -0,0 +1,172 @@
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
38
+ full list of directives available from the DSL.
39
+
40
+ -D, \--daemonize
41
+ : Run daemonized in the background. The process is detached from
42
+ the controlling terminal and stdin is redirected to "/dev/null".
43
+ Unlike many common UNIX daemons, we do not chdir to \"/\"
44
+ upon daemonization to allow more control over the startup/upgrade
45
+ process.
46
+ Unless specified in the CONFIG_FILE, stderr and stdout will
47
+ also be redirected to "/dev/null".
48
+ Daemonization will _skip_ loading of the *Rails::Rack::LogTailer*
49
+ middleware under Rails \>\= 2.3.x.
50
+ By default, unicorn\_rails(1) will create a PID file in
51
+ _\"RAILS\_ROOT/tmp/pids/unicorn.pid\"_. You may override this
52
+ by specifying the "pid" directive to override this Unicorn config file.
53
+
54
+ -E, \--env RAILS_ENV
55
+ : Run under the given RAILS_ENV. This sets the RAILS_ENV environment
56
+ variable. Acceptable values are exactly those you expect in your Rails
57
+ application, typically "development" or "production".
58
+
59
+ -l, \--listen ADDRESS
60
+ : Listens on a given ADDRESS. ADDRESS may be in the form of
61
+ HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
62
+ and PATH is meant to be a path to a UNIX domain socket.
63
+ Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080).
64
+ For production deployments, specifying the "listen" directive in
65
+ CONFIG_FILE is recommended as it allows fine-tuning of socket
66
+ options.
67
+
68
+ # RACKUP COMPATIBILITY OPTIONS
69
+ -o, \--host HOST
70
+ : Listen on a TCP socket belonging to HOST, default is
71
+ "0.0.0.0" (all addresses).
72
+ If specified multiple times on the command-line, only the
73
+ last-specified value takes effect.
74
+ This option only exists for compatibility with the rackup(1) command,
75
+ use of "-l"/"\--listen" switch is recommended instead.
76
+
77
+ -p, \--port PORT
78
+ : Listen on the specified TCP PORT, default is 8080.
79
+ If specified multiple times on the command-line, only the last-specified
80
+ value takes effect.
81
+ This option only exists for compatibility with the rackup(1) command,
82
+ use of "-l"/"\--listen" switch is recommended instead.
83
+
84
+ \--path PATH
85
+ : Mounts the Rails application at the given PATH (instead of "/").
86
+ This is equivalent to setting the RAILS_RELATIVE_URL_ROOT
87
+ environment variable. This is only supported under Rails 2.3
88
+ or later at the moment.
89
+
90
+ # RUBY OPTIONS
91
+ -e, \--eval LINE
92
+ : Evaluate a LINE of Ruby code. This evaluation happens
93
+ immediately as the command-line is being parsed.
94
+
95
+ -d, \--debug
96
+ : Turn on debug mode, the $DEBUG variable is set to true.
97
+ For Rails \>\= 2.3.x, this loads the *Rails::Rack::Debugger*
98
+ middleware.
99
+
100
+ -w, \--warn
101
+ : Turn on verbose warnings, the $VERBOSE variable is set to true.
102
+
103
+ -I, \--include PATH
104
+ : specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
105
+ The \':\' character may be used to delimit multiple directories.
106
+ This directive may be used more than once. Modifications to
107
+ $LOAD_PATH take place immediately and in the order they were
108
+ specified on the command-line.
109
+
110
+ -r, \--require LIBRARY
111
+ : require a specified LIBRARY before executing the application. The
112
+ \"require\" statement will be executed immediately and in the order
113
+ they were specified on the command-line.
114
+
115
+ # RACKUP FILE
116
+
117
+ This defaults to \"config.ru\" in RAILS_ROOT. It should be the same
118
+ file used by rackup(1) and other Rack launchers, it uses the
119
+ *Rack::Builder* DSL. Unlike many other Rack applications, RACKUP_FILE
120
+ is completely _optional_ for Rails, but may be used to disable some
121
+ of the default middleware for performance.
122
+
123
+ Embedded command-line options are mostly parsed for compatibility
124
+ with rackup(1) but strongly discouraged.
125
+
126
+ # ENVIRONMENT VARIABLES
127
+
128
+ The RAILS_ENV variable is set by the aforementioned \-E switch. The
129
+ RAILS_RELATIVE_URL_ROOT is set by the aforementioned \--path switch.
130
+ Either of these variables may also be set in the shell or the Unicorn
131
+ CONFIG_FILE. All application or library-specific environment variables
132
+ (e.g. TMPDIR, RAILS_ASSET_ID) may always be set in the Unicorn
133
+ CONFIG_FILE in addition to the spawning shell. When transparently
134
+ upgrading Unicorn, all environment variables set in the old master
135
+ process are inherited by the new master process. Unicorn only uses (and
136
+ will overwrite) the UNICORN_FD environment variable internally when
137
+ doing transparent upgrades.
138
+
139
+ # SIGNALS
140
+
141
+ The following UNIX signals may be sent to the master process:
142
+
143
+ * HUP - reload config file, app, and gracefully restart all workers
144
+ * INT/TERM - quick shutdown, kills all workers immediately
145
+ * QUIT - graceful shutdown, waits for workers to finish their
146
+ current request before finishing.
147
+ * USR1 - reopen all logs owned by the master and all workers
148
+ See Unicorn::Util.reopen_logs for what is considered a log.
149
+ * USR2 - reexecute the running binary. A separate QUIT
150
+ should be sent to the original process once the child is verified to
151
+ be up and running.
152
+ * WINCH - gracefully stops workers but keep the master running.
153
+ This will only work for daemonized processes.
154
+ * TTIN - increment the number of worker processes by one
155
+ * TTOU - decrement the number of worker processes by one
156
+
157
+ See the [SIGNALS][4] document for full description of all signals
158
+ used by Unicorn.
159
+
160
+ # SEE ALSO
161
+
162
+ * unicorn(1)
163
+ * *Rack::Builder* ri/RDoc
164
+ * *Unicorn::Configurator* ri/RDoc
165
+ * [Unicorn RDoc][1]
166
+ * [Rack RDoc][2]
167
+ * [Rackup HowTo][3]
168
+
169
+ [1]: http://unicorn.bogomips.org/
170
+ [2]: http://rack.rubyforge.org/doc/
171
+ [3]: http://wiki.github.com/rack/rack/tutorial-rackup-howto
172
+ [4]: http://unicorn.bogomips.org/SIGNALS.html