tests: upgrade to rack 1.5.1
[unicorn.git] / Documentation / unicorn_rails.1.txt
blobf426b07ebd181598d4c9b533af980ce8f1bb73f1
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 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.
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.
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".
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.
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.
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.
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.
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.
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.
103 -w, \--warn
104 :   Turn on verbose warnings, the $VERBOSE variable is set to true.
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.
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.
118 # RACKUP FILE
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.
126 Embedded command-line options are mostly parsed for compatibility
127 with rackup(1) but strongly discouraged.
129 # ENVIRONMENT VARIABLES
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.
142 # SIGNALS
144 The following UNIX signals may be sent to the master process:
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
160 See the [SIGNALS][4] document for full description of all signals
161 used by Unicorn.
163 # SEE ALSO
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]
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