giraffesoft-unicorn 0.93.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. data/.CHANGELOG.old +25 -0
  2. data/.document +16 -0
  3. data/.gitignore +20 -0
  4. data/.mailmap +26 -0
  5. data/CONTRIBUTORS +31 -0
  6. data/COPYING +339 -0
  7. data/DESIGN +105 -0
  8. data/Documentation/.gitignore +5 -0
  9. data/Documentation/GNUmakefile +30 -0
  10. data/Documentation/unicorn.1.txt +167 -0
  11. data/Documentation/unicorn_rails.1.txt +169 -0
  12. data/GIT-VERSION-GEN +40 -0
  13. data/GNUmakefile +270 -0
  14. data/HACKING +113 -0
  15. data/KNOWN_ISSUES +40 -0
  16. data/LICENSE +55 -0
  17. data/PHILOSOPHY +144 -0
  18. data/README +153 -0
  19. data/Rakefile +108 -0
  20. data/SIGNALS +97 -0
  21. data/TODO +16 -0
  22. data/TUNING +70 -0
  23. data/bin/unicorn +165 -0
  24. data/bin/unicorn_rails +208 -0
  25. data/examples/echo.ru +27 -0
  26. data/examples/git.ru +13 -0
  27. data/examples/init.sh +53 -0
  28. data/ext/unicorn_http/c_util.h +107 -0
  29. data/ext/unicorn_http/common_field_optimization.h +111 -0
  30. data/ext/unicorn_http/ext_help.h +73 -0
  31. data/ext/unicorn_http/extconf.rb +14 -0
  32. data/ext/unicorn_http/global_variables.h +91 -0
  33. data/ext/unicorn_http/unicorn_http.rl +715 -0
  34. data/ext/unicorn_http/unicorn_http_common.rl +74 -0
  35. data/lib/unicorn.rb +730 -0
  36. data/lib/unicorn/app/exec_cgi.rb +150 -0
  37. data/lib/unicorn/app/inetd.rb +109 -0
  38. data/lib/unicorn/app/old_rails.rb +31 -0
  39. data/lib/unicorn/app/old_rails/static.rb +60 -0
  40. data/lib/unicorn/cgi_wrapper.rb +145 -0
  41. data/lib/unicorn/configurator.rb +403 -0
  42. data/lib/unicorn/const.rb +37 -0
  43. data/lib/unicorn/http_request.rb +74 -0
  44. data/lib/unicorn/http_response.rb +74 -0
  45. data/lib/unicorn/launcher.rb +39 -0
  46. data/lib/unicorn/socket_helper.rb +138 -0
  47. data/lib/unicorn/tee_input.rb +174 -0
  48. data/lib/unicorn/util.rb +64 -0
  49. data/local.mk.sample +53 -0
  50. data/setup.rb +1586 -0
  51. data/test/aggregate.rb +15 -0
  52. data/test/benchmark/README +50 -0
  53. data/test/benchmark/dd.ru +18 -0
  54. data/test/exec/README +5 -0
  55. data/test/exec/test_exec.rb +855 -0
  56. data/test/rails/app-1.2.3/.gitignore +2 -0
  57. data/test/rails/app-1.2.3/Rakefile +7 -0
  58. data/test/rails/app-1.2.3/app/controllers/application.rb +6 -0
  59. data/test/rails/app-1.2.3/app/controllers/foo_controller.rb +36 -0
  60. data/test/rails/app-1.2.3/app/helpers/application_helper.rb +4 -0
  61. data/test/rails/app-1.2.3/config/boot.rb +11 -0
  62. data/test/rails/app-1.2.3/config/database.yml +12 -0
  63. data/test/rails/app-1.2.3/config/environment.rb +13 -0
  64. data/test/rails/app-1.2.3/config/environments/development.rb +9 -0
  65. data/test/rails/app-1.2.3/config/environments/production.rb +5 -0
  66. data/test/rails/app-1.2.3/config/routes.rb +6 -0
  67. data/test/rails/app-1.2.3/db/.gitignore +0 -0
  68. data/test/rails/app-1.2.3/public/404.html +1 -0
  69. data/test/rails/app-1.2.3/public/500.html +1 -0
  70. data/test/rails/app-2.0.2/.gitignore +2 -0
  71. data/test/rails/app-2.0.2/Rakefile +7 -0
  72. data/test/rails/app-2.0.2/app/controllers/application.rb +4 -0
  73. data/test/rails/app-2.0.2/app/controllers/foo_controller.rb +36 -0
  74. data/test/rails/app-2.0.2/app/helpers/application_helper.rb +4 -0
  75. data/test/rails/app-2.0.2/config/boot.rb +11 -0
  76. data/test/rails/app-2.0.2/config/database.yml +12 -0
  77. data/test/rails/app-2.0.2/config/environment.rb +17 -0
  78. data/test/rails/app-2.0.2/config/environments/development.rb +8 -0
  79. data/test/rails/app-2.0.2/config/environments/production.rb +5 -0
  80. data/test/rails/app-2.0.2/config/routes.rb +6 -0
  81. data/test/rails/app-2.0.2/db/.gitignore +0 -0
  82. data/test/rails/app-2.0.2/public/404.html +1 -0
  83. data/test/rails/app-2.0.2/public/500.html +1 -0
  84. data/test/rails/app-2.1.2/.gitignore +2 -0
  85. data/test/rails/app-2.1.2/Rakefile +7 -0
  86. data/test/rails/app-2.1.2/app/controllers/application.rb +4 -0
  87. data/test/rails/app-2.1.2/app/controllers/foo_controller.rb +36 -0
  88. data/test/rails/app-2.1.2/app/helpers/application_helper.rb +4 -0
  89. data/test/rails/app-2.1.2/config/boot.rb +111 -0
  90. data/test/rails/app-2.1.2/config/database.yml +12 -0
  91. data/test/rails/app-2.1.2/config/environment.rb +17 -0
  92. data/test/rails/app-2.1.2/config/environments/development.rb +7 -0
  93. data/test/rails/app-2.1.2/config/environments/production.rb +5 -0
  94. data/test/rails/app-2.1.2/config/routes.rb +6 -0
  95. data/test/rails/app-2.1.2/db/.gitignore +0 -0
  96. data/test/rails/app-2.1.2/public/404.html +1 -0
  97. data/test/rails/app-2.1.2/public/500.html +1 -0
  98. data/test/rails/app-2.2.2/.gitignore +2 -0
  99. data/test/rails/app-2.2.2/Rakefile +7 -0
  100. data/test/rails/app-2.2.2/app/controllers/application.rb +4 -0
  101. data/test/rails/app-2.2.2/app/controllers/foo_controller.rb +36 -0
  102. data/test/rails/app-2.2.2/app/helpers/application_helper.rb +4 -0
  103. data/test/rails/app-2.2.2/config/boot.rb +111 -0
  104. data/test/rails/app-2.2.2/config/database.yml +12 -0
  105. data/test/rails/app-2.2.2/config/environment.rb +17 -0
  106. data/test/rails/app-2.2.2/config/environments/development.rb +7 -0
  107. data/test/rails/app-2.2.2/config/environments/production.rb +5 -0
  108. data/test/rails/app-2.2.2/config/routes.rb +6 -0
  109. data/test/rails/app-2.2.2/db/.gitignore +0 -0
  110. data/test/rails/app-2.2.2/public/404.html +1 -0
  111. data/test/rails/app-2.2.2/public/500.html +1 -0
  112. data/test/rails/app-2.3.3.1/.gitignore +2 -0
  113. data/test/rails/app-2.3.3.1/Rakefile +7 -0
  114. data/test/rails/app-2.3.3.1/app/controllers/application_controller.rb +5 -0
  115. data/test/rails/app-2.3.3.1/app/controllers/foo_controller.rb +36 -0
  116. data/test/rails/app-2.3.3.1/app/helpers/application_helper.rb +4 -0
  117. data/test/rails/app-2.3.3.1/config/boot.rb +109 -0
  118. data/test/rails/app-2.3.3.1/config/database.yml +12 -0
  119. data/test/rails/app-2.3.3.1/config/environment.rb +17 -0
  120. data/test/rails/app-2.3.3.1/config/environments/development.rb +7 -0
  121. data/test/rails/app-2.3.3.1/config/environments/production.rb +6 -0
  122. data/test/rails/app-2.3.3.1/config/routes.rb +6 -0
  123. data/test/rails/app-2.3.3.1/db/.gitignore +0 -0
  124. data/test/rails/app-2.3.3.1/public/404.html +1 -0
  125. data/test/rails/app-2.3.3.1/public/500.html +1 -0
  126. data/test/rails/app-2.3.3.1/public/x.txt +1 -0
  127. data/test/rails/test_rails.rb +280 -0
  128. data/test/test_helper.rb +296 -0
  129. data/test/unit/test_configurator.rb +150 -0
  130. data/test/unit/test_http_parser.rb +492 -0
  131. data/test/unit/test_http_parser_ng.rb +308 -0
  132. data/test/unit/test_request.rb +184 -0
  133. data/test/unit/test_response.rb +110 -0
  134. data/test/unit/test_server.rb +188 -0
  135. data/test/unit/test_signals.rb +202 -0
  136. data/test/unit/test_socket_helper.rb +133 -0
  137. data/test/unit/test_tee_input.rb +229 -0
  138. data/test/unit/test_upload.rb +297 -0
  139. data/test/unit/test_util.rb +96 -0
  140. data/unicorn.gemspec +42 -0
  141. metadata +228 -0
data/DESIGN ADDED
@@ -0,0 +1,105 @@
1
+ == Design
2
+
3
+ * Simplicity: Unicorn is a traditional UNIX prefork web server.
4
+ No threads are used at all, this makes applications easier to debug
5
+ and fix. When your application goes awry, a BOFH can just
6
+ "kill -9" the runaway worker process without worrying about tearing
7
+ all clients down, just one. Only UNIX-like systems supporting
8
+ fork() and file descriptor inheritance are supported.
9
+
10
+ * The Ragel+C HTTP parser is taken from Mongrel. This is the
11
+ only non-Ruby part and there are no plans to add any more
12
+ non-Ruby components.
13
+
14
+ * All HTTP protocol parsing and I/O is done much like Mongrel:
15
+ 1. read/parse HTTP request headers in full
16
+ 2. call Rack application
17
+ 3. write HTTP response back to the client
18
+
19
+ * Like Mongrel, neither keepalive nor pipelining are supported.
20
+ These aren't needed since Unicorn is only designed to serve
21
+ fast, low-latency clients directly. Do one thing, do it well;
22
+ let nginx handle slow clients.
23
+
24
+ * Configuration is purely in Ruby and eval(). Ruby is less
25
+ ambiguous than YAML and lets lambdas for
26
+ before_fork/after_fork/before_exec hooks be defined inline. An
27
+ optional, separate config_file may be used to modify supported
28
+ configuration changes (and also gives you plenty of rope if you RTFS
29
+ :>)
30
+
31
+ * One master process spawns and reaps worker processes. The
32
+ Rack application itself is called only within the worker process (but
33
+ can be loaded within the master). A copy-on-write friendly garbage
34
+ collector like Ruby Enterprise Edition can be used to minimize memory
35
+ usage along with the "preload_app true" directive (see
36
+ Unicorn::Configurator).
37
+
38
+ * The number of worker processes should be scaled to the number of
39
+ CPUs, memory or even spindles you have. If you have an existing
40
+ Mongrel cluster on a single-threaded app, using the same amount of
41
+ processes should work. Let a full-HTTP-request-buffering reverse
42
+ proxy like nginx manage concurrency to thousands of slow clients for
43
+ you. Unicorn scaling should only be concerned about limits of your
44
+ backend system(s).
45
+
46
+ * Load balancing between worker processes is done by the OS kernel.
47
+ All workers share a common set of listener sockets and does
48
+ non-blocking accept() on them. The kernel will decide which worker
49
+ process to give a socket to and workers will sleep if there is
50
+ nothing to accept().
51
+
52
+ * Since non-blocking accept() is used, there can be a thundering
53
+ herd when an occasional client connects when application
54
+ *is not busy*. The thundering herd problem should not affect
55
+ applications that are running all the time since worker processes
56
+ will only select()/accept() outside of the application dispatch.
57
+
58
+ * Additionally, thundering herds are much smaller than with
59
+ configurations using existing prefork servers. Process counts should
60
+ only be scaled to backend resources, _never_ to the number of expected
61
+ clients like is typical with blocking prefork servers. So while we've
62
+ seen instances of popular prefork servers configured to run many
63
+ hundreds of worker processes, Unicorn deployments are typically only
64
+ 2-4 processes per-core.
65
+
66
+ * On-demand scaling of worker processes never happens automatically.
67
+ Again, Unicorn is concerned about scaling to backend limits and should
68
+ never configured in a fashion where it could be waiting on slow
69
+ clients. For extremely rare circumstances, we provide TTIN and TTOU
70
+ signal handlers to increment/decrement your process counts without
71
+ reloading. Think of it as driving a car with manual transmission:
72
+ you have a lot more control if you know what you're doing.
73
+
74
+ * Blocking I/O is used for clients. This allows a simpler code path
75
+ to be followed within the Ruby interpreter and fewer syscalls.
76
+ Applications that use threads continue to work if Unicorn
77
+ is only serving LAN or localhost clients.
78
+
79
+ * Timeout implementation is done via fchmod(2) in each worker
80
+ on a shared file descriptor to update st_ctime on the inode.
81
+ Master process wakeups for checking on timeouts is throttled
82
+ one a second to minimize the performance impact and simplify
83
+ the code path within the worker. Neither futimes(2) nor
84
+ pwrite(2)/pread(2) are supported by base MRI, nor are they as
85
+ portable on UNIX systems as fchmod(2).
86
+
87
+ * SIGKILL is used to terminate the timed-out workers from misbehaving apps
88
+ as reliably as possible on a UNIX system. The default timeout is a
89
+ generous 60 seconds (same default as in Mongrel).
90
+
91
+ * The poor performance of select() on large FD sets is avoided
92
+ as few file descriptors are used in each worker.
93
+ There should be no gain from moving to highly scalable but
94
+ unportable event notification solutions for watching few
95
+ file descriptors.
96
+
97
+ * If the master process dies unexpectedly for any reason,
98
+ workers will notice within :timeout/2 seconds and follow
99
+ the master to its death.
100
+
101
+ * There is never any explicit real-time dependency or communication
102
+ between the worker processes nor to the master process.
103
+ Synchronization is handled entirely by the OS kernel and shared
104
+ resources are never accessed by the worker when it is servicing
105
+ a client.
@@ -0,0 +1,5 @@
1
+ *.1
2
+ *.5
3
+ *.7
4
+ *.gz
5
+ *.html
@@ -0,0 +1,30 @@
1
+ all::
2
+
3
+ PANDOC = pandoc
4
+ PANDOC_OPTS = -f markdown --email-obfuscation=none --sanitize-html
5
+ pandoc = $(PANDOC) $(PANDOC_OPTS)
6
+ pandoc_html = $(pandoc) --toc -t html --no-wrap
7
+
8
+ man1 := $(addsuffix .1,unicorn unicorn_rails)
9
+ html1 := $(addsuffix .html,$(man1))
10
+
11
+ all:: html man
12
+
13
+ html: $(html1)
14
+ man: $(man1)
15
+
16
+ install-html: html
17
+ mkdir -p ../doc/man1
18
+ install -m 644 $(html1) ../doc/man1
19
+
20
+ install-man: man
21
+ mkdir -p ../man/man1
22
+ install -m 644 $(man1) ../man/man1
23
+
24
+ %.1: %.1.txt
25
+ $(pandoc) -s -t man < $< > $@+ && mv $@+ $@
26
+ %.1.html: %.1.txt
27
+ $(pandoc_html) < $< > $@+ && mv $@+ $@
28
+
29
+ clean::
30
+ $(RM) $(man1) $(html1)
@@ -0,0 +1,167 @@
1
+ % UNICORN(1) Unicorn User Manual
2
+ % The Unicorn Community <mongrel-unicorn@rubyforge.org>
3
+ % September 15, 2009
4
+
5
+ # NAME
6
+
7
+ unicorn - a rackup-like command to launch the Unicorn HTTP server
8
+
9
+ # SYNOPSIS
10
+
11
+ unicorn [-c CONFIG_FILE] [-E RACK_ENV] [-D] [RACKUP_FILE]
12
+
13
+ # DESCRIPTION
14
+
15
+ A rackup(1)-like command to launch Rack applications using Unicorn.
16
+ It is expected to be started in your application root (APP_ROOT), but
17
+ "Dir.chdir" may also be executed in the CONFIG_FILE or RACKUP_FILE.
18
+
19
+ While Unicorn takes a myriad of command-line options for
20
+ compatibility with ruby(1) and rackup(1), it is recommended to stick
21
+ to the few command-line options specified in the SYNOPSIS and use
22
+ the CONFIG_FILE as much as possible.
23
+
24
+ # RACKUP FILE
25
+
26
+ This defaults to \"config.ru\" in APP_ROOT. It should be the same
27
+ file used by rackup(1) and other Rack launchers, it uses the
28
+ *Rack::Builder* DSL.
29
+
30
+ Embedded command-line options are mostly parsed for compatibility
31
+ with rackup(1) but strongly discouraged.
32
+
33
+ # UNICORN OPTIONS
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 (e.g.
37
+ "Dir.chdir", "Process::UID.change_privilege"). See the RDoc/ri
38
+ for the *Unicorn::Configurator* class for the full list of
39
+ directives available from the DSL.
40
+
41
+ -D, \--daemonize
42
+ : Run daemonized in the background. The process is detached from
43
+ the controlling terminal and stdin is redirected to "/dev/null".
44
+ Unlike many common UNIX daemons, we do not chdir to \"/\"
45
+ upon daemonization to allow more control over the startup/upgrade
46
+ process.
47
+ Unless specified in the CONFIG_FILE, stderr and stdout will
48
+ also be redirected to "/dev/null".
49
+
50
+ -E, \--env RACK_ENV
51
+ : Run under the given RACK_ENV. See the RACK ENVIRONMENT section
52
+ for more details.
53
+
54
+ -l, \--listen ADDRESS
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
61
+ options.
62
+
63
+ # RACKUP COMPATIBILITY OPTIONS
64
+ -o, \--host HOST
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.
71
+
72
+ -p, \--port PORT
73
+ : Listen on the specified TCP PORT, default is 8080.
74
+ If specified multiple times on the command-line, only the last-specified
75
+ value takes effect.
76
+ This option only exists for compatibility with the rackup(1) command,
77
+ use of "-l"/"\--listen" switch is recommended instead.
78
+
79
+ -s, \--server SERVER
80
+ : No-op, this exists only for compatibility with rackup(1).
81
+
82
+ # RUBY OPTIONS
83
+ -e, \--eval LINE
84
+ : Evaluate a LINE of Ruby code. This evaluation happens
85
+ immediately as the command-line is being parsed.
86
+
87
+ -d, \--debug
88
+ : Turn on debug mode, the $DEBUG variable is set to true.
89
+
90
+ -w, \--warn
91
+ : Turn on verbose warnings, the $VERBOSE variable is set to true.
92
+
93
+ -I, \--include PATH
94
+ : specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
95
+ The \':\' character may be used to delimit multiple directories.
96
+ This directive may be used more than once. Modifications to
97
+ $LOAD_PATH take place immediately and in the order they were
98
+ specified on the command-line.
99
+
100
+ -r, \--require LIBRARY
101
+ : require a specified LIBRARY before executing the application. The
102
+ \"require\" statement will be executed immediately and in the order
103
+ they were specified on the command-line.
104
+
105
+ # SIGNALS
106
+
107
+ The following UNIX signals may be sent to the master process:
108
+
109
+ * HUP - reload config file, app, and gracefully restart all workers
110
+ * INT/TERM - quick shutdown, kills all workers immediately
111
+ * QUIT - graceful shutdown, waits for workers to finish their
112
+ current request before finishing.
113
+ * USR1 - reopen all logs owned by the master and all workers
114
+ See Unicorn::Util.reopen_logs for what is considered a log.
115
+ * USR2 - reexecute the running binary. A separate QUIT
116
+ should be sent to the original process once the child is verified to
117
+ be up and running.
118
+ * WINCH - gracefully stops workers but keep the master running.
119
+ This will only work for daemonized processes.
120
+ * TTIN - increment the number of worker processes by one
121
+ * TTOU - decrement the number of worker processes by one
122
+
123
+ See the [SIGNALS][4] document for full description of all signals
124
+ used by Unicorn.
125
+
126
+ # RACK ENVIRONMENT
127
+
128
+ Accepted values of RACK_ENV and the middleware they automatically load
129
+ (outside of RACKUP_FILE) are exactly as those in rackup(1):
130
+
131
+ * development - loads Rack::CommonLogger, Rack::ShowExceptions, and
132
+ Rack::Lint middleware
133
+ * deployment - loads Rack::CommonLogger middleware
134
+ * none - loads no middleware at all, relying
135
+ entirely on RACKUP_FILE
136
+
137
+ All unrecognized values for RACK_ENV are assumed to be
138
+ "none". Production deployments are strongly encouraged to use
139
+ "deployment" or "none" for maximum performance.
140
+
141
+ Note that the Rack::ContentLength and Rack::Chunked middlewares
142
+ are never loaded by default. If needed, they should be
143
+ individually specified in the RACKUP_FILE, some frameworks do
144
+ not require them.
145
+
146
+ # ENVIRONMENT VARIABLES
147
+
148
+ All application or library-specific environment variables (e.g. TMPDIR)
149
+ may always be set in the Unicorn CONFIG_FILE in addition to the spawning
150
+ shell. When transparently upgrading Unicorn, all environment variables
151
+ set in the old master process are inherited by the new master process.
152
+ Unicorn only uses (and will overwrite) the UNICORN_FD environment
153
+ variable internally when doing transparent upgrades.
154
+
155
+ # SEE ALSO
156
+
157
+ * unicorn_rails(1)
158
+ * *Rack::Builder* ri/RDoc
159
+ * *Unicorn::Configurator* ri/RDoc
160
+ * [Unicorn RDoc][1]
161
+ * [Rack RDoc][2]
162
+ * [Rackup HowTo][3]
163
+
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
@@ -0,0 +1,169 @@
1
+ % UNICORN_RAILS(1) Unicorn User Manual
2
+ % The Unicorn Community <mongrel-unicorn@rubyforge.org>
3
+ % September 17, 2009
4
+
5
+ # NAME
6
+
7
+ unicorn_rails - a rackup-like command to launch the Unicorn HTTP server
8
+
9
+ # SYNOPSIS
10
+
11
+ unicorn_rails [-c CONFIG_FILE] [-E RAILS_ENV] [-D] [RACKUP_FILE]
12
+
13
+ # DESCRIPTION
14
+
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 "Dir.chdir" may also be executed in the CONFIG_FILE or
18
+ optionally, RACKUP_FILE.
19
+
20
+ The outward interface resembles rackup(1), the internals and default
21
+ middleware loading is designed like the `script/server` command
22
+ distributed with Rails.
23
+
24
+ While Unicorn takes a myriad of command-line options for compatibility
25
+ with ruby(1) and rackup(1), it is recommended to stick to the few
26
+ command-line options specified in the SYNOPSIS and use the CONFIG_FILE
27
+ as much as possible.
28
+
29
+ # UNICORN OPTIONS
30
+ -c, \--config-file CONFIG_FILE
31
+ : Path to the Unicorn-specific config file. The config file is
32
+ implemented as a Ruby DSL, so Ruby code may executed (e.g.
33
+ "Dir.chdir", "Process::UID.change_privilege"). See the RDoc/ri
34
+ for the *Unicorn::Configurator* class for the full list of
35
+ directives available from the DSL.
36
+
37
+ -D, \--daemonize
38
+ : Run daemonized in the background. The process is detached from
39
+ the controlling terminal and stdin is redirected to "/dev/null".
40
+ Unlike many common UNIX daemons, we do not chdir to \"/\"
41
+ upon daemonization to allow more control over the startup/upgrade
42
+ process.
43
+ Unless specified in the CONFIG_FILE, stderr and stdout will
44
+ also be redirected to "/dev/null".
45
+ Daemonization will _skip_ loading of the *Rails::Rack::LogTailer*
46
+ middleware under Rails \>\= 2.3.x.
47
+ By default, unicorn\_rails(1) will create a PID file in
48
+ _\"RAILS\_ROOT/tmp/pids/unicorn.pid\"_. You may override this
49
+ by specifying the "pid" directive to override this Unicorn config file.
50
+
51
+ -E, \--env RAILS_ENV
52
+ : Run under the given RAILS_ENV. This sets the RAILS_ENV environment
53
+ variable. Acceptable values are exactly those you expect in your Rails
54
+ application, typically "development" or "production".
55
+
56
+ -l, \--listen ADDRESS
57
+ : Listens on a given ADDRESS. ADDRESS may be in the form of
58
+ HOST:PORT or PATH, HOST:PORT is taken to mean a TCP socket
59
+ and PATH is meant to be a path to a UNIX domain socket.
60
+ Defaults to "0.0.0.0:8080" (all addresses on TCP port 8080).
61
+ For production deployments, specifying the "listen" directive in
62
+ CONFIG_FILE is recommended as it allows fine-tuning of socket
63
+ options.
64
+
65
+ # RACKUP COMPATIBILITY OPTIONS
66
+ -o, \--host HOST
67
+ : Listen on a TCP socket belonging to HOST, default is
68
+ "0.0.0.0" (all addresses).
69
+ If specified multiple times on the command-line, only the
70
+ last-specified value takes effect.
71
+ This option only exists for compatibility with the rackup(1) command,
72
+ use of "-l"/"\--listen" switch is recommended instead.
73
+
74
+ -p, \--port PORT
75
+ : Listen on the specified TCP PORT, default is 8080.
76
+ If specified multiple times on the command-line, only the last-specified
77
+ value takes effect.
78
+ This option only exists for compatibility with the rackup(1) command,
79
+ use of "-l"/"\--listen" switch is recommended instead.
80
+
81
+ \--path PATH
82
+ : Mounts the Rails application at the given PATH (instead of "/").
83
+ This is equivalent to setting the RAILS_RELATIVE_URL_ROOT
84
+ environment variable. This is only supported under Rails 2.3
85
+ or later at the moment.
86
+
87
+ # RUBY OPTIONS
88
+ -e, \--eval LINE
89
+ : Evaluate a LINE of Ruby code. This evaluation happens
90
+ immediately as the command-line is being parsed.
91
+
92
+ -d, \--debug
93
+ : Turn on debug mode, the $DEBUG variable is set to true.
94
+ For Rails \>\= 2.3.x, this loads the *Rails::Rack::Debugger*
95
+ middleware.
96
+
97
+ -w, \--warn
98
+ : Turn on verbose warnings, the $VERBOSE variable is set to true.
99
+
100
+ -I, \--include PATH
101
+ : specify $LOAD_PATH. PATH will be prepended to $LOAD_PATH.
102
+ The \':\' character may be used to delimit multiple directories.
103
+ This directive may be used more than once. Modifications to
104
+ $LOAD_PATH take place immediately and in the order they were
105
+ specified on the command-line.
106
+
107
+ -r, \--require LIBRARY
108
+ : require a specified LIBRARY before executing the application. The
109
+ \"require\" statement will be executed immediately and in the order
110
+ they were specified on the command-line.
111
+
112
+ # RACKUP FILE
113
+
114
+ This defaults to \"config.ru\" in RAILS_ROOT. It should be the same
115
+ file used by rackup(1) and other Rack launchers, it uses the
116
+ *Rack::Builder* DSL. Unlike many other Rack applications, RACKUP_FILE
117
+ is completely _optional_ for Rails, but may be used to disable some
118
+ of the default middleware for performance.
119
+
120
+ Embedded command-line options are mostly parsed for compatibility
121
+ with rackup(1) but strongly discouraged.
122
+
123
+ # ENVIRONMENT VARIABLES
124
+
125
+ The RAILS_ENV variable is set by the aforementioned \-E switch. The
126
+ RAILS_RELATIVE_URL_ROOT is set by the aforementioned \--path switch.
127
+ Either of these variables may also be set in the shell or the Unicorn
128
+ CONFIG_FILE. All application or library-specific environment variables
129
+ (e.g. TMPDIR, RAILS_ASSET_ID) may always be set in the Unicorn
130
+ CONFIG_FILE in addition to the spawning shell. When transparently
131
+ upgrading Unicorn, all environment variables set in the old master
132
+ process are inherited by the new master process. Unicorn only uses (and
133
+ will overwrite) the UNICORN_FD environment variable internally when
134
+ doing transparent upgrades.
135
+
136
+ # SIGNALS
137
+
138
+ The following UNIX signals may be sent to the master process:
139
+
140
+ * HUP - reload config file, app, and gracefully restart all workers
141
+ * INT/TERM - quick shutdown, kills all workers immediately
142
+ * QUIT - graceful shutdown, waits for workers to finish their
143
+ current request before finishing.
144
+ * USR1 - reopen all logs owned by the master and all workers
145
+ 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
148
+ be up and running.
149
+ * WINCH - gracefully stops workers but keep the master running.
150
+ This will only work for daemonized processes.
151
+ * TTIN - increment the number of worker processes by one
152
+ * TTOU - decrement the number of worker processes by one
153
+
154
+ See the [SIGNALS][4] document for full description of all signals
155
+ used by Unicorn.
156
+
157
+ # SEE ALSO
158
+
159
+ * unicorn(1)
160
+ * *Rack::Builder* ri/RDoc
161
+ * *Unicorn::Configurator* ri/RDoc
162
+ * [Unicorn RDoc][1]
163
+ * [Rack RDoc][2]
164
+ * [Rackup HowTo][3]
165
+
166
+ [1]: http://unicorn.bogomips.org/
167
+ [2]: http://rack.rubyforge.org/doc/
168
+ [3]: http://wiki.github.com/rack/rack/tutorial-rackup-howto
169
+ [4]: http://unicorn.bogomips.org/SIGNALS.html