1 % UNICORN_RAILS(1) Unicorn User Manual
2 % The Unicorn Community <mongrel-unicorn@rubyforge.org>
7 unicorn_rails - a script/server-like command to launch the Unicorn HTTP server
11 unicorn_rails [-c CONFIG_FILE] [-E RAILS_ENV] [-D] [RACKUP_FILE]
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
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.
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
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.
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".
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
68 # RACKUP COMPATIBILITY OPTIONS
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.
78 : Listen on the specified TCP PORT, default is 8080.
79 If specified multiple times on the command-line, only the last-specified
81 This option only exists for compatibility with the rackup(1) command,
82 use of "-l"/"\--listen" switch is recommended instead.
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.
92 : Evaluate a LINE of Ruby code. This evaluation happens
93 immediately as the command-line is being parsed.
96 : Turn on debug mode, the $DEBUG variable is set to true.
97 For Rails \>\= 2.3.x, this loads the *Rails::Rack::Debugger*
101 : Turn on verbose warnings, the $VERBOSE variable is set to true.
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.
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.
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
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
163 * *Rack::Builder* ri/RDoc
164 * *Unicorn::Configurator* ri/RDoc
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