1 % UNICORN_RAILS(1) Unicorn User Manual
2 % The Unicorn Community <mongrel-unicorn@rubyforge.org>
7 unicorn_rails - a rackup-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 The outward interface resembles rackup(1), the internals and default
20 middleware loading is designed like the `script/server` command
21 distributed with Rails.
23 While Unicorn takes a myriad of command-line options for compatibility
24 with ruby(1) and rackup(1), it is recommended to stick to the few
25 command-line options specified in the SYNOPSIS and use the CONFIG_FILE
29 -c, \--config-file CONFIG_FILE
30 : Path to the Unicorn-specific config file. The config file is
31 implemented as a Ruby DSL, so Ruby code may executed.
32 See the RDoc/ri for the *Unicorn::Configurator* class for the
33 full list of directives available from the DSL.
36 : Run daemonized in the background. The process is detached from
37 the controlling terminal and stdin is redirected to "/dev/null".
38 Unlike many common UNIX daemons, we do not chdir to \"/\"
39 upon daemonization to allow more control over the startup/upgrade
41 Unless specified in the CONFIG_FILE, stderr and stdout will
42 also be redirected to "/dev/null".
43 Daemonization will _skip_ loading of the *Rails::Rack::LogTailer*
44 middleware under Rails \>\= 2.3.x.
45 By default, unicorn\_rails(1) will create a PID file in
46 _\"RAILS\_ROOT/tmp/pids/unicorn.pid\"_. You may override this
47 by specifying the "pid" directive to override this Unicorn config file.
50 : Run under the given RAILS_ENV. This sets the RAILS_ENV environment
51 variable. Acceptable values are exactly those you expect in your Rails
52 application, typically "development" or "production".
55 : Listens on a given ADDRESS. ADDRESS may be in the form of
56 HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
57 and PATH is meant to be a path to a UNIX domain socket.
58 Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080).
59 For production deployments, specifying the "listen" directive in
60 CONFIG_FILE is recommended as it allows fine-tuning of socket
63 # RACKUP COMPATIBILITY OPTIONS
65 : Listen on a TCP socket belonging to HOST, default is
66 "0.0.0.0" (all addresses).
67 If specified multiple times on the command-line, only the
68 last-specified value takes effect.
69 This option only exists for compatibility with the rackup(1) command,
70 use of "-l"/"\--listen" switch is recommended instead.
73 : Listen on the specified TCP PORT, default is 8080.
74 If specified multiple times on the command-line, only the last-specified
76 This option only exists for compatibility with the rackup(1) command,
77 use of "-l"/"\--listen" switch is recommended instead.
80 : Mounts the Rails application at the given PATH (instead of "/").
81 This is equivalent to setting the RAILS_RELATIVE_URL_ROOT
82 environment variable. This is only supported under Rails 2.3
83 or later at the moment.
87 : Evaluate a LINE of Ruby code. This evaluation happens
88 immediately as the command-line is being parsed.
91 : Turn on debug mode, the $DEBUG variable is set to true.
92 For Rails \>\= 2.3.x, this loads the *Rails::Rack::Debugger*
96 : Turn on verbose warnings, the $VERBOSE variable is set to true.
99 : specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
100 The \':\' character may be used to delimit multiple directories.
101 This directive may be used more than once. Modifications to
102 $LOAD_PATH take place immediately and in the order they were
103 specified on the command-line.
105 -r, \--require LIBRARY
106 : require a specified LIBRARY before executing the application. The
107 \"require\" statement will be executed immediately and in the order
108 they were specified on the command-line.
112 This defaults to \"config.ru\" in RAILS_ROOT. It should be the same
113 file used by rackup(1) and other Rack launchers, it uses the
114 *Rack::Builder* DSL. Unlike many other Rack applications, RACKUP_FILE
115 is completely _optional_ for Rails, but may be used to disable some
116 of the default middleware for performance.
118 Embedded command-line options are mostly parsed for compatibility
119 with rackup(1) but strongly discouraged.
121 # ENVIRONMENT VARIABLES
123 The RAILS_ENV variable is set by the aforementioned \-E switch. The
124 RAILS_RELATIVE_URL_ROOT is set by the aforementioned \--path switch.
125 Either of these variables may also be set in the shell or the Unicorn
126 CONFIG_FILE. All application or library-specific environment variables
127 (e.g. TMPDIR, RAILS_ASSET_ID) may always be set in the Unicorn
128 CONFIG_FILE in addition to the spawning shell. When transparently
129 upgrading Unicorn, all environment variables set in the old master
130 process are inherited by the new master process. Unicorn only uses (and
131 will overwrite) the UNICORN_FD environment variable internally when
132 doing transparent upgrades.
136 The following UNIX signals may be sent to the master process:
138 * HUP - reload config file, app, and gracefully restart all workers
139 * INT/TERM - quick shutdown, kills all workers immediately
140 * QUIT - graceful shutdown, waits for workers to finish their
141 current request before finishing.
142 * USR1 - reopen all logs owned by the master and all workers
143 See Unicorn::Util.reopen_logs for what is considered a log.
144 * USR2 - reexecute the running binary. A separate QUIT
145 should be sent to the original process once the child is verified to
147 * WINCH - gracefully stops workers but keep the master running.
148 This will only work for daemonized processes.
149 * TTIN - increment the number of worker processes by one
150 * TTOU - decrement the number of worker processes by one
152 See the [SIGNALS][4] document for full description of all signals
158 * *Rack::Builder* ri/RDoc
159 * *Unicorn::Configurator* ri/RDoc
164 [1]: http://unicorn.bogomips.org/
165 [2]: http://rack.rubyforge.org/doc/
166 [3]: http://wiki.github.com/rack/rack/tutorial-rackup-howto
167 [4]: http://unicorn.bogomips.org/SIGNALS.html