tee_input: update documentation for Rack 1.2
[unicorn.git] / Documentation / unicorn_rails.1.txt
blob267e42561131f0eedd2e25fbf7eb81d456c279c9
1 % UNICORN_RAILS(1) Unicorn User Manual
2 % The Unicorn Community <mongrel-unicorn@rubyforge.org>
3 % September 17, 2009
5 # NAME
7 unicorn_rails - a script/server-like command to launch the Unicorn HTTP server
9 # SYNOPSIS
11 unicorn_rails [-c CONFIG_FILE] [-E RAILS_ENV] [-D] [RACKUP_FILE]
13 # DESCRIPTION
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.
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).
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.
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.
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.
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.
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".
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.
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.
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.
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.
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.
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.
100 -w, \--warn
101 :   Turn on verbose warnings, the $VERBOSE variable is set to true.
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.
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.
115 # RACKUP FILE
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.
123 Embedded command-line options are mostly parsed for compatibility
124 with rackup(1) but strongly discouraged.
126 # ENVIRONMENT VARIABLES
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.
139 # SIGNALS
141 The following UNIX signals may be sent to the master process:
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
157 See the [SIGNALS][4] document for full description of all signals
158 used by Unicorn.
160 # SEE ALSO
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]
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