t/lib.perl: fix Perl integration tests w/o installation
[unicorn.git] / Documentation / unicorn_rails.1
blobfec0a2aa85f75ac95200cdcc6b638c7875807624
1 .TH "UNICORN_RAILS" "1" "September 17, 2009" "Unicorn User Manual" ""
2 .hy
3 .SH NAME
4 .PP
5 unicorn_rails \- unicorn launcher for Rails 1.x and 2.x users
6 .SH SYNOPSIS
7 .PP
8 unicorn_rails [\-c CONFIG_FILE] [\-E RAILS_ENV] [\-D] [RACKUP_FILE]
9 .SH DESCRIPTION
10 .PP
11 A rackup(1)\-like command to launch ancient Rails (2.x and earlier)
12 applications using Unicorn.  Rails 3 (and later) support Rack natively,
13 so users are encouraged to use unicorn(1) instead of unicorn_rails(1).
14 .PP
15 It is expected to be started in your Rails application root (RAILS_ROOT),
16 but the "working_directory" directive may be used in the CONFIG_FILE.
17 .PP
18 The outward interface resembles rackup(1), the internals and default
19 middleware loading is designed like the \f[C]script/server\f[] command
20 distributed with Rails.
21 .PP
22 While Unicorn takes a myriad of command\-line options for compatibility
23 with ruby(1) and rackup(1), it is recommended to stick to the few
24 command\-line options specified in the SYNOPSIS and use the CONFIG_FILE
25 as much as possible.
26 .SH UNICORN OPTIONS
27 .TP
28 .B \-c, \-\-config\-file CONFIG_FILE
29 Path to the Unicorn\-specific config file.  The config file is
30 implemented as a Ruby DSL, so Ruby code may executed.
31 See the RDoc/ri for the \f[I]Unicorn::Configurator\f[] class for the full
32 list of directives available from the DSL.
33 Using an absolute path for for CONFIG_FILE is recommended as it
34 makes multiple instances of Unicorn easily distinguishable when
35 viewing ps(1) output.
36 .RS
37 .RE
38 .TP
39 .B \-D, \-\-daemonize
40 Run daemonized in the background.  The process is detached from
41 the controlling terminal and stdin is redirected to "/dev/null".
42 Unlike many common UNIX daemons, we do not chdir to "/" upon
43 daemonization to allow more control over the startup/upgrade
44 process.
45 Unless specified in the CONFIG_FILE, stderr and stdout will
46 also be redirected to "/dev/null".
47 Daemonization will \f[I]skip\f[] loading of the
48 \f[I]Rails::Rack::LogTailer\f[]
49 middleware under Rails >= 2.3.x.
50 By default, unicorn_rails(1) will create a PID file in
51 \f[I]"RAILS_ROOT/tmp/pids/unicorn.pid"\f[].  You may override this
52 by specifying the "pid" directive to override this Unicorn config file.
53 .RS
54 .RE
55 .TP
56 .B \-E, \-\-env RAILS_ENV
57 Run under the given RAILS_ENV.  This sets the RAILS_ENV environment
58 variable.  Acceptable values are exactly those you expect in your Rails
59 application, typically "development" or "production".
60 .RS
61 .RE
62 .TP
63 .B \-l, \-\-listen ADDRESS
64 Listens on a given ADDRESS.  ADDRESS may be in the form of
65 HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
66 and PATH is meant to be a path to a UNIX domain socket.
67 Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080).
68 For production deployments, specifying the "listen" directive in
69 CONFIG_FILE is recommended as it allows fine\-tuning of socket
70 options.
71 .RS
72 .RE
73 .SH RACKUP COMPATIBILITY OPTIONS
74 .TP
75 .B \-o, \-\-host HOST
76 Listen on a TCP socket belonging to HOST, default is
77 "0.0.0.0" (all addresses).
78 If specified multiple times on the command\-line, only the
79 last\-specified value takes effect.
80 This option only exists for compatibility with the rackup(1) command,
81 use of "\-l"/"\-\-listen" switch is recommended instead.
82 .RS
83 .RE
84 .TP
85 .B \-p, \-\-port PORT
86 Listen on the specified TCP PORT, default is 8080.
87 If specified multiple times on the command\-line, only the last\-specified
88 value takes effect.
89 This option only exists for compatibility with the rackup(1) command,
90 use of "\-l"/"\-\-listen" switch is recommended instead.
91 .RS
92 .RE
93 .TP
94 .B \-\-path PATH
95 Mounts the Rails application at the given PATH (instead of "/").
96 This is equivalent to setting the RAILS_RELATIVE_URL_ROOT
97 environment variable.  This is only supported under Rails 2.3
98 or later at the moment.
99 .RS
101 .SH RUBY OPTIONS
103 .B \-e, \-\-eval LINE
104 Evaluate a LINE of Ruby code.  This evaluation happens
105 immediately as the command\-line is being parsed.
109 .B \-d, \-\-debug
110 Turn on debug mode, the $DEBUG variable is set to true.
111 For Rails >= 2.3.x, this loads the \f[I]Rails::Rack::Debugger\f[]
112 middleware.
116 .B \-w, \-\-warn
117 Turn on verbose warnings, the $VERBOSE variable is set to true.
121 .B \-I, \-\-include PATH
122 specify $LOAD_PATH.  PATH will be prepended to $LOAD_PATH.
123 The \[aq]:\[aq] character may be used to delimit multiple directories.
124 This directive may be used more than once.  Modifications to
125 $LOAD_PATH take place immediately and in the order they were
126 specified on the command\-line.
130 .B \-r, \-\-require LIBRARY
131 require a specified LIBRARY before executing the application.  The
132 "require" statement will be executed immediately and in the order
133 they were specified on the command\-line.
136 .SH RACKUP FILE
138 This defaults to "config.ru" in RAILS_ROOT.  It should be the same
139 file used by rackup(1) and other Rack launchers, it uses the
140 \f[I]Rack::Builder\f[] DSL.  Unlike many other Rack applications, RACKUP_FILE
141 is completely \f[I]optional\f[] for Rails, but may be used to disable
142 some of the default middleware for performance.
144 Embedded command\-line options are mostly parsed for compatibility
145 with rackup(1) but strongly discouraged.
146 .SH ENVIRONMENT VARIABLES
148 The RAILS_ENV variable is set by the aforementioned \-E switch.  The
149 RAILS_RELATIVE_URL_ROOT is set by the aforementioned \-\-path switch.
150 Either of these variables may also be set in the shell or the Unicorn
151 CONFIG_FILE.  All application or library\-specific environment variables
152 (e.g. TMPDIR, RAILS_ASSET_ID) may always be set in the Unicorn
153 CONFIG_FILE in addition to the spawning shell.  When transparently
154 upgrading Unicorn, all environment variables set in the old master
155 process are inherited by the new master process.  Unicorn only uses (and
156 will overwrite) the UNICORN_FD environment variable internally when
157 doing transparent upgrades.
158 .SH SIGNALS
160 The following UNIX signals may be sent to the master process:
161 .IP \[bu] 2
162 HUP \- reload config file, app, and gracefully restart all workers
163 .IP \[bu] 2
164 INT/TERM \- quick shutdown, kills all workers immediately
165 .IP \[bu] 2
166 QUIT \- graceful shutdown, waits for workers to finish their current
167 request before finishing.
168 .IP \[bu] 2
169 USR1 \- reopen all logs owned by the master and all workers
170 See Unicorn::Util.reopen_logs for what is considered a log.
171 .IP \[bu] 2
172 USR2 \- reexecute the running binary.  A separate QUIT
173 should be sent to the original process once the child is verified to
174 be up and running.
175 .IP \[bu] 2
176 WINCH \- gracefully stops workers but keep the master running.
177 This will only work for daemonized processes.
178 .IP \[bu] 2
179 TTIN \- increment the number of worker processes by one
180 .IP \[bu] 2
181 TTOU \- decrement the number of worker processes by one
183 See the SIGNALS (https://yhbt.net/unicorn/SIGNALS.html) document for
184 full description of all signals used by Unicorn.
185 .SH SEE ALSO
186 .IP \[bu] 2
187 unicorn(1)
188 .IP \[bu] 2
189 \f[I]Rack::Builder\f[] ri/RDoc
190 .IP \[bu] 2
191 \f[I]Unicorn::Configurator\f[] ri/RDoc
192 .UR https://yhbt.net/unicorn/Unicorn/Configurator.html
194 .IP \[bu] 2
195 unicorn RDoc
196 .UR https://yhbt.net/unicorn/
198 .IP \[bu] 2
199 Rack RDoc
200 .UR https://www.rubydoc.info/github/rack/rack/
202 .IP \[bu] 2
203 Rackup HowTo
204 .UR https://github.com/rack/rack/wiki/(tutorial)-rackup-howto
206 .SH AUTHORS
207 The Unicorn Community <unicorn-public@yhbt.net>.