---
name: "unicorn_rails"
section: "1"
platform: "linux"
package: "unicorn"
version: "6.1.0+git.20250131.1370f52-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/unicorn_rails"
---

# unicorn\_rails(1)

unicorn launcher for Rails 1.x and 2.x users

## NAME

unicorn\_rails - unicorn launcher for Rails 1.x and 2.x users

## SYNOPSIS

unicorn\_rails \[-c CONFIG\_FILE\] \[-E RAILS\_ENV\] \[-D\] \[RACKUP\_FILE\]

## DESCRIPTION

A [rackup(1)](/rackup/1.md)-like command to launch ancient Rails (2.x and earlier) applications using Unicorn.  Rails 3 (and later) support Rack natively, so users are encouraged to use [unicorn(1)](/unicorn/1.md) instead of [unicorn\_rails(1)](/unicorn_rails/1.md).

It is expected to be started in your Rails application root (RAILS\_ROOT), but the "working\_directory" directive may be used in the CONFIG\_FILE.

The outward interface resembles [rackup(1)](/rackup/1.md), the internals and default middleware loading is designed like the `script/server` command distributed with Rails.

While Unicorn takes a myriad of command-line options for compatibility with [ruby(1)](/ruby/1.md) and [rackup(1)](/rackup/1.md), it is recommended to stick to the few command-line options specified in the SYNOPSIS and use the CONFIG\_FILE as much as possible.

## UNICORN OPTIONS

- **-c, --config-file CONFIG\_FILE**

  Path to the Unicorn-specific config file.  The config file is implemented as a Ruby DSL, so Ruby code may executed. See the RDoc/ri for the *Unicorn::Configurator* class for the full list of directives available from the DSL. Using an absolute path for for CONFIG\_FILE is recommended as it makes multiple instances of Unicorn easily distinguishable when viewing [ps(1)](/ps/1.md) output.

- **-D, --daemonize**

  Run daemonized in the background.  The process is detached from the controlling terminal and stdin is redirected to "/dev/null". Unlike many common UNIX daemons, we do not chdir to "/" upon daemonization to allow more control over the startup/upgrade process. Unless specified in the CONFIG\_FILE, stderr and stdout will also be redirected to "/dev/null". Daemonization will *skip* loading of the *Rails::Rack::LogTailer* middleware under Rails \>= 2.3.x. By default, [unicorn\_rails(1)](/unicorn_rails/1.md) will create a PID file in *"RAILS\_ROOT/tmp/pids/unicorn.pid"*.  You may override this by specifying the "pid" directive to override this Unicorn config file.

- **-E, --env RAILS\_ENV**

  Run under the given RAILS\_ENV.  This sets the RAILS\_ENV environment variable.  Acceptable values are exactly those you expect in your Rails application, typically "development" or "production".

- **-l, --listen ADDRESS**

  Listens on a given ADDRESS.  ADDRESS may be in the form of HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket and PATH is meant to be a path to a UNIX domain socket. Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080). For production deployments, specifying the "listen" directive in CONFIG\_FILE is recommended as it allows fine-tuning of socket options.

## RACKUP COMPATIBILITY OPTIONS

- **-o, --host HOST**

  Listen on a TCP socket belonging to HOST, default is "0.0.0.0" (all addresses). If specified multiple times on the command-line, only the last-specified value takes effect. This option only exists for compatibility with the [rackup(1)](/rackup/1.md) command, use of "-l"/"--listen" switch is recommended instead.

- **-p, --port PORT**

  Listen on the specified TCP PORT, default is 8080. If specified multiple times on the command-line, only the last-specified value takes effect. This option only exists for compatibility with the [rackup(1)](/rackup/1.md) command, use of "-l"/"--listen" switch is recommended instead.

- **--path PATH**

  Mounts the Rails application at the given PATH (instead of "/"). This is equivalent to setting the RAILS\_RELATIVE\_URL\_ROOT environment variable.  This is only supported under Rails 2.3 or later at the moment.

## RUBY OPTIONS

- **-e, --eval LINE**

  Evaluate a LINE of Ruby code.  This evaluation happens immediately as the command-line is being parsed.

- **-d, --debug**

  Turn on debug mode, the $DEBUG variable is set to true. For Rails \>= 2.3.x, this loads the *Rails::Rack::Debugger* middleware.

- **-w, --warn**

  Turn on verbose warnings, the $VERBOSE variable is set to true.

- **-I, --include PATH**

  specify $LOAD\_PATH.  PATH will be prepended to $LOAD\_PATH. The ':' character may be used to delimit multiple directories. This directive may be used more than once.  Modifications to $LOAD\_PATH take place immediately and in the order they were specified on the command-line.

- **-r, --require LIBRARY**

  require a specified LIBRARY before executing the application.  The "require" statement will be executed immediately and in the order they were specified on the command-line.

## RACKUP FILE

This defaults to "config.ru" in RAILS\_ROOT.  It should be the same file used by [rackup(1)](/rackup/1.md) and other Rack launchers, it uses the *Rack::Builder* DSL.  Unlike many other Rack applications, RACKUP\_FILE is completely *optional* for Rails, but may be used to disable some of the default middleware for performance.

Embedded command-line options are mostly parsed for compatibility with [rackup(1)](/rackup/1.md) but strongly discouraged.

## ENVIRONMENT VARIABLES

The RAILS\_ENV variable is set by the aforementioned -E switch.  The RAILS\_RELATIVE\_URL\_ROOT is set by the aforementioned --path switch. Either of these variables may also be set in the shell or the Unicorn CONFIG\_FILE.  All application or library-specific environment variables (e.g. TMPDIR, RAILS\_ASSET\_ID) may always be set in the Unicorn CONFIG\_FILE in addition to the spawning shell.  When transparently upgrading Unicorn, all environment variables set in the old master process are inherited by the new master process.  Unicorn only uses (and will overwrite) the UNICORN\_FD environment variable internally when doing transparent upgrades.

## SIGNALS

The following UNIX signals may be sent to the master process:

- •

  HUP - reload config file, app, and gracefully restart all workers

- •

  INT/TERM - quick shutdown, kills all workers immediately

- •

  QUIT - graceful shutdown, waits for workers to finish their current request before finishing.

- •

  USR1 - reopen all logs owned by the master and all workers See Unicorn::Util.reopen\_logs for what is considered a log.

- •

  USR2 - reexecute the running binary.  A separate QUIT should be sent to the original process once the child is verified to be up and running.

- •

  WINCH - gracefully stops workers but keep the master running. This will only work for daemonized processes.

- •

  TTIN - increment the number of worker processes by one

- •

  TTOU - decrement the number of worker processes by one

See the SIGNALS (https://yhbt.net/unicorn/SIGNALS.html) document for full description of all signals used by Unicorn.

## SEE ALSO

- •

  [unicorn(1)](/unicorn/1.md)

- •

  *Rack::Builder* ri/RDoc

- •

  *Unicorn::Configurator* ri/RDoc ⟨https://yhbt.net/unicorn/Unicorn/Configurator.html⟩

- •

  unicorn RDoc ⟨https://yhbt.net/unicorn/⟩

- •

  Rack RDoc ⟨https://www.rubydoc.info/github/rack/rack/⟩

- •

  Rackup HowTo ⟨https://github.com/rack/rack/wiki/(tutorial)-rackup-howto⟩

## AUTHORS

The Unicorn Community \<unicorn-public@yhbt.net\>.
