1 .TH "UNICORN" "1" "September 15, 2009" "Unicorn User Manual" ""
5 unicorn \- a rackup\-like command to launch the Unicorn HTTP server
8 unicorn [\-c CONFIG_FILE] [\-E RACK_ENV] [\-D] [RACKUP_FILE]
11 A rackup(1)\-like command to launch Rack applications using Unicorn.
12 It is expected to be started in your application root (APP_ROOT),
13 but the "working_directory" directive may be used in the CONFIG_FILE.
15 While unicorn takes a myriad of command\-line options for
16 compatibility with ruby(1) and rackup(1), it is recommended to stick
17 to the few command\-line options specified in the SYNOPSIS and use
18 the CONFIG_FILE as much as possible.
21 This defaults to "config.ru" in APP_ROOT. It should be the same
22 file used by rackup(1) and other Rack launchers, it uses the
23 \f[I]Rack::Builder\f[] DSL.
25 Embedded command\-line options are mostly parsed for compatibility
26 with rackup(1) but strongly discouraged.
29 .B \-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 \f[I]Unicorn::Configurator\f[] class for the full
33 list of directives available from the DSL.
34 Using an absolute path for for CONFIG_FILE is recommended as it
35 makes multiple instances of Unicorn easily distinguishable when
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".
51 .B \-E, \-\-env RACK_ENV
52 Run under the given RACK_ENV. See the RACK ENVIRONMENT section
57 .B \-l, \-\-listen ADDRESS
58 Listens on a given ADDRESS. ADDRESS may be in the form of
59 HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
60 and PATH is meant to be a path to a UNIX domain socket.
61 Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080)
62 For production deployments, specifying the "listen" directive in
63 CONFIG_FILE is recommended as it allows fine\-tuning of socket
68 .B \-N, \-\-no\-default\-middleware
69 Disables loading middleware implied by RACK_ENV. This bypasses the
70 configuration documented in the RACK ENVIRONMENT section, but still
71 allows RACK_ENV to be used for application/framework\-specific purposes.
74 .SH RACKUP COMPATIBILITY OPTIONS
77 Listen on a TCP socket belonging to HOST, default is
78 "0.0.0.0" (all addresses).
79 If specified multiple times on the command\-line, only the
80 last\-specified value takes effect.
81 This option only exists for compatibility with the rackup(1) command,
82 use of "\-l"/"\-\-listen" switch is recommended instead.
87 Listen on the specified TCP PORT, default is 8080.
88 If specified multiple times on the command\-line, only the last\-specified
90 This option only exists for compatibility with the rackup(1) command,
91 use of "\-l"/"\-\-listen" switch is recommended instead.
95 .B \-s, \-\-server SERVER
96 No\-op, this exists only for compatibility with rackup(1).
101 .B \-e, \-\-eval LINE
102 Evaluate a LINE of Ruby code. This evaluation happens
103 immediately as the command\-line is being parsed.
108 Turn on debug mode, the $DEBUG variable is set to true.
113 Turn on verbose warnings, the $VERBOSE variable is set to true.
117 .B \-I, \-\-include PATH
118 specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
119 The \[aq]:\[aq] character may be used to delimit multiple directories.
120 This directive may be used more than once. Modifications to
121 $LOAD_PATH take place immediately and in the order they were
122 specified on the command\-line.
126 .B \-r, \-\-require LIBRARY
127 require a specified LIBRARY before executing the application. The
128 "require" statement will be executed immediately and in the order
129 they were specified on the command\-line.
134 The following UNIX signals may be sent to the master process:
136 HUP \- reload config file, app, and gracefully restart all workers
138 INT/TERM \- quick shutdown, kills all workers immediately
140 QUIT \- graceful shutdown, waits for workers to finish their
141 current request before finishing.
143 USR1 \- reopen all logs owned by the master and all workers
144 See Unicorn::Util.reopen_logs for what is considered a log.
146 USR2 \- reexecute the running binary. A separate QUIT
147 should be sent to the original process once the child is verified to
150 WINCH \- gracefully stops workers but keep the master running.
151 This will only work for daemonized processes.
153 TTIN \- increment the number of worker processes by one
155 TTOU \- decrement the number of worker processes by one
157 See the SIGNALS (https://yhbt.net/unicorn/SIGNALS.html) document for
158 full description of all signals used by Unicorn.
161 Accepted values of RACK_ENV and the middleware they automatically load
162 (outside of RACKUP_FILE) are exactly as those in rackup(1):
164 development \- loads Rack::CommonLogger, Rack::ShowExceptions, and
165 Rack::Lint middleware
167 deployment \- loads Rack::CommonLogger middleware
169 none \- loads no middleware at all, relying entirely on RACKUP_FILE
171 All unrecognized values for RACK_ENV are assumed to be
172 "none". Production deployments are strongly encouraged to use
173 "deployment" or "none" for maximum performance.
175 As of Unicorn 0.94.0, RACK_ENV is exported as a process\-wide environment
176 variable as well. While not current a part of the Rack specification as
177 of Rack 1.0.1, this has become a de facto standard in the Rack world.
179 Note the Rack::ContentLength middleware is also
180 loaded by "deployment" and "development", but no other values of
181 RACK_ENV. If needed, they must be individually specified in the
182 RACKUP_FILE, some frameworks do not require them.
183 .SH ENVIRONMENT VARIABLES
185 The RACK_ENV variable is set by the aforementioned \-E switch.
186 All application or library\-specific environment variables (e.g. TMPDIR)
187 may always be set in the Unicorn CONFIG_FILE in addition to the spawning
188 shell. When transparently upgrading Unicorn, all environment variables
189 set in the old master process are inherited by the new master process.
190 Unicorn only uses (and will overwrite) the UNICORN_FD environment
191 variable internally when doing transparent upgrades.
193 UNICORN_FD is a comma\-delimited list of one or more file descriptors
194 used to implement USR2 upgrades. Init systems may bind listen sockets
195 itself and spawn unicorn with UNICORN_FD set to the file descriptor
196 numbers of the listen socket(s).
198 As of unicorn 5.0, LISTEN_PID and LISTEN_FDS are used for socket
199 activation as documented in the sd_listen_fds(3) manpage. Users
200 relying on this feature do not need to specify a listen socket in
201 the unicorn config file.
204 \f[I]Rack::Builder\f[] ri/RDoc
206 \f[I]Unicorn::Configurator\f[] ri/RDoc
207 .UR https://yhbt.net/unicorn/Unicorn/Configurator.html
211 .UR https://yhbt.net/unicorn/
215 .UR https://www.rubydoc.info/github/rack/rack/
219 .UR https://github.com/rack/rack/wiki/(tutorial)-rackup-howto
222 The Unicorn Community <unicorn-public@yhbt.net>.