unicorn-fork 6.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. checksums.yaml +7 -0
  2. data/.CHANGELOG.old +25 -0
  3. data/.document +28 -0
  4. data/.gitattributes +5 -0
  5. data/.gitignore +25 -0
  6. data/.mailmap +26 -0
  7. data/.manifest +144 -0
  8. data/.olddoc.yml +25 -0
  9. data/Application_Timeouts +77 -0
  10. data/CONTRIBUTORS +39 -0
  11. data/COPYING +674 -0
  12. data/DESIGN +99 -0
  13. data/Documentation/.gitignore +3 -0
  14. data/Documentation/unicorn.1 +222 -0
  15. data/Documentation/unicorn_rails.1 +207 -0
  16. data/FAQ +70 -0
  17. data/GIT-VERSION-FILE +1 -0
  18. data/GIT-VERSION-GEN +39 -0
  19. data/GNUmakefile +318 -0
  20. data/HACKING +117 -0
  21. data/ISSUES +102 -0
  22. data/KNOWN_ISSUES +79 -0
  23. data/LICENSE +67 -0
  24. data/Links +58 -0
  25. data/PHILOSOPHY +139 -0
  26. data/README +165 -0
  27. data/Rakefile +17 -0
  28. data/SIGNALS +123 -0
  29. data/Sandbox +104 -0
  30. data/TODO +1 -0
  31. data/TUNING +119 -0
  32. data/archive/.gitignore +3 -0
  33. data/archive/slrnpull.conf +4 -0
  34. data/bin/unicorn +129 -0
  35. data/bin/unicorn_rails +210 -0
  36. data/examples/big_app_gc.rb +3 -0
  37. data/examples/echo.ru +27 -0
  38. data/examples/init.sh +102 -0
  39. data/examples/logger_mp_safe.rb +26 -0
  40. data/examples/logrotate.conf +44 -0
  41. data/examples/nginx.conf +156 -0
  42. data/examples/unicorn.conf.minimal.rb +14 -0
  43. data/examples/unicorn.conf.rb +111 -0
  44. data/examples/unicorn.socket +11 -0
  45. data/examples/unicorn@.service +40 -0
  46. data/ext/unicorn_http/CFLAGS +13 -0
  47. data/ext/unicorn_http/c_util.h +115 -0
  48. data/ext/unicorn_http/common_field_optimization.h +128 -0
  49. data/ext/unicorn_http/epollexclusive.h +128 -0
  50. data/ext/unicorn_http/ext_help.h +38 -0
  51. data/ext/unicorn_http/extconf.rb +40 -0
  52. data/ext/unicorn_http/global_variables.h +97 -0
  53. data/ext/unicorn_http/httpdate.c +91 -0
  54. data/ext/unicorn_http/unicorn_http.c +4348 -0
  55. data/ext/unicorn_http/unicorn_http.rl +1054 -0
  56. data/ext/unicorn_http/unicorn_http_common.rl +76 -0
  57. data/lib/unicorn/app/old_rails/static.rb +60 -0
  58. data/lib/unicorn/app/old_rails.rb +36 -0
  59. data/lib/unicorn/cgi_wrapper.rb +148 -0
  60. data/lib/unicorn/configurator.rb +749 -0
  61. data/lib/unicorn/const.rb +22 -0
  62. data/lib/unicorn/http_request.rb +180 -0
  63. data/lib/unicorn/http_response.rb +95 -0
  64. data/lib/unicorn/http_server.rb +860 -0
  65. data/lib/unicorn/launcher.rb +63 -0
  66. data/lib/unicorn/oob_gc.rb +82 -0
  67. data/lib/unicorn/preread_input.rb +34 -0
  68. data/lib/unicorn/select_waiter.rb +7 -0
  69. data/lib/unicorn/socket_helper.rb +186 -0
  70. data/lib/unicorn/stream_input.rb +152 -0
  71. data/lib/unicorn/tee_input.rb +132 -0
  72. data/lib/unicorn/tmpio.rb +34 -0
  73. data/lib/unicorn/util.rb +91 -0
  74. data/lib/unicorn/version.rb +1 -0
  75. data/lib/unicorn/worker.rb +166 -0
  76. data/lib/unicorn.rb +137 -0
  77. data/man/man1/unicorn.1 +222 -0
  78. data/man/man1/unicorn_rails.1 +207 -0
  79. data/setup.rb +1587 -0
  80. data/t/.gitignore +4 -0
  81. data/t/GNUmakefile +5 -0
  82. data/t/README +49 -0
  83. data/t/active-unix-socket.t +110 -0
  84. data/t/back-out-of-upgrade.t +44 -0
  85. data/t/bin/unused_listen +40 -0
  86. data/t/client_body_buffer_size.ru +15 -0
  87. data/t/client_body_buffer_size.t +79 -0
  88. data/t/detach.ru +12 -0
  89. data/t/env.ru +4 -0
  90. data/t/fails-rack-lint.ru +6 -0
  91. data/t/heartbeat-timeout.ru +13 -0
  92. data/t/heartbeat-timeout.t +60 -0
  93. data/t/integration.ru +129 -0
  94. data/t/integration.t +509 -0
  95. data/t/lib.perl +309 -0
  96. data/t/listener_names.ru +5 -0
  97. data/t/my-tap-lib.sh +201 -0
  98. data/t/oob_gc.ru +18 -0
  99. data/t/oob_gc_path.ru +18 -0
  100. data/t/pid.ru +4 -0
  101. data/t/preread_input.ru +23 -0
  102. data/t/reload-bad-config.t +49 -0
  103. data/t/reopen-logs.ru +14 -0
  104. data/t/reopen-logs.t +36 -0
  105. data/t/t0010-reap-logging.sh +55 -0
  106. data/t/t0012-reload-empty-config.sh +86 -0
  107. data/t/t0013-rewindable-input-false.sh +24 -0
  108. data/t/t0013.ru +13 -0
  109. data/t/t0014-rewindable-input-true.sh +24 -0
  110. data/t/t0014.ru +13 -0
  111. data/t/t0015-configurator-internals.sh +25 -0
  112. data/t/t0020-at_exit-handler.sh +49 -0
  113. data/t/t0021-process_detach.sh +29 -0
  114. data/t/t0022-listener_names-preload_app.sh +32 -0
  115. data/t/t0300-no-default-middleware.sh +20 -0
  116. data/t/t0301-no-default-middleware-ignored-in-config.sh +25 -0
  117. data/t/t0301.ru +14 -0
  118. data/t/t9001-oob_gc.sh +47 -0
  119. data/t/t9002-oob_gc-path.sh +75 -0
  120. data/t/test-lib.sh +125 -0
  121. data/t/winch_ttin.t +64 -0
  122. data/t/working_directory.t +86 -0
  123. data/test/aggregate.rb +16 -0
  124. data/test/benchmark/README +60 -0
  125. data/test/benchmark/dd.ru +19 -0
  126. data/test/benchmark/ddstream.ru +51 -0
  127. data/test/benchmark/readinput.ru +41 -0
  128. data/test/benchmark/stack.ru +9 -0
  129. data/test/benchmark/uconnect.perl +66 -0
  130. data/test/exec/README +5 -0
  131. data/test/exec/test_exec.rb +1030 -0
  132. data/test/test_helper.rb +307 -0
  133. data/test/unit/test_configurator.rb +176 -0
  134. data/test/unit/test_droplet.rb +29 -0
  135. data/test/unit/test_http_parser.rb +885 -0
  136. data/test/unit/test_http_parser_ng.rb +715 -0
  137. data/test/unit/test_server.rb +245 -0
  138. data/test/unit/test_signals.rb +189 -0
  139. data/test/unit/test_socket_helper.rb +160 -0
  140. data/test/unit/test_stream_input.rb +211 -0
  141. data/test/unit/test_tee_input.rb +304 -0
  142. data/test/unit/test_util.rb +132 -0
  143. data/test/unit/test_waiter.rb +35 -0
  144. data/unicorn.gemspec +49 -0
  145. metadata +266 -0
data/DESIGN ADDED
@@ -0,0 +1,99 @@
1
+ == Design
2
+
3
+ Unicorn was designed to support poorly-written codebases back in 2008.
4
+ Its unfortunate popularity has only proliferated the existence of
5
+ poorly-written code ever since...
6
+
7
+ * Simplicity: Unicorn is a traditional UNIX prefork web server.
8
+ No threads are used at all, this makes applications easier to debug
9
+ and fix. When your application goes awry, a BOFH can just
10
+ "kill -9" the runaway worker process without worrying about tearing
11
+ all clients down, just one. Only UNIX-like systems supporting
12
+ fork() and file descriptor inheritance are supported.
13
+
14
+ * The Ragel+C HTTP parser is taken from Mongrel.
15
+
16
+ * All HTTP parsing and I/O is done much like Mongrel:
17
+ 1. read/parse HTTP request headers in full
18
+ 2. call Rack application
19
+ 3. write HTTP response back to the client
20
+
21
+ * Like Mongrel, neither keepalive nor pipelining are supported.
22
+ These aren't needed since Unicorn is only designed to serve
23
+ fast, low-latency clients directly. Do one thing, do it well;
24
+ let nginx handle slow clients.
25
+
26
+ * Configuration is purely in Ruby and eval(). Ruby is less
27
+ ambiguous than YAML and lets lambdas for
28
+ before_fork/after_fork/before_exec hooks be defined inline. An
29
+ optional, separate config_file may be used to modify supported
30
+ configuration changes (and also gives you plenty of rope if you RTFS
31
+ :>)
32
+
33
+ * One master process spawns and reaps worker processes. The
34
+ Rack application itself is called only within the worker process (but
35
+ can be loaded within the master). A copy-on-write friendly garbage
36
+ collector like the one found in mainline Ruby 2.0.0 and later
37
+ can be used to minimize memory usage along with the "preload_app true"
38
+ directive (see Unicorn::Configurator).
39
+
40
+ * The number of worker processes should be scaled to the number of
41
+ CPUs, memory or even spindles you have. If you have an existing
42
+ Mongrel cluster on a single-threaded app, using the same amount of
43
+ processes should work. Let a full-HTTP-request-buffering reverse
44
+ proxy like nginx manage concurrency to thousands of slow clients for
45
+ you. Unicorn scaling should only be concerned about limits of your
46
+ backend system(s).
47
+
48
+ * Load balancing between worker processes is done by the OS kernel.
49
+ All workers share a common set of listener sockets and does
50
+ non-blocking accept() on them. The kernel will decide which worker
51
+ process to give a socket to and workers will sleep if there is
52
+ nothing to accept().
53
+
54
+ * Since non-blocking accept() is used, there can be a thundering
55
+ herd when an occasional client connects when application
56
+ *is not busy*. The thundering herd problem should not affect
57
+ applications that are running all the time since worker processes
58
+ will only select()/accept() outside of the application dispatch.
59
+
60
+ * Additionally, thundering herds are much smaller than with
61
+ configurations using existing prefork servers. Process counts should
62
+ only be scaled to backend resources, _never_ to the number of expected
63
+ clients like is typical with blocking prefork servers. So while we've
64
+ seen instances of popular prefork servers configured to run many
65
+ hundreds of worker processes, Unicorn deployments are typically only
66
+ 2-4 processes per-core.
67
+
68
+ * On-demand scaling of worker processes never happens automatically.
69
+ Again, Unicorn is concerned about scaling to backend limits and should
70
+ never configured in a fashion where it could be waiting on slow
71
+ clients. For extremely rare circumstances, we provide TTIN and TTOU
72
+ signal handlers to increment/decrement your process counts without
73
+ reloading. Think of it as driving a car with manual transmission:
74
+ you have a lot more control if you know what you're doing.
75
+
76
+ * Blocking I/O is used for clients. This allows a simpler code path
77
+ to be followed within the Ruby interpreter and fewer syscalls.
78
+ Applications that use threads continue to work if Unicorn
79
+ is only serving LAN or localhost clients.
80
+
81
+ * SIGKILL is used to terminate the timed-out workers from misbehaving apps
82
+ as reliably as possible on a UNIX system. The default timeout is a
83
+ generous 60 seconds (same default as in Mongrel).
84
+
85
+ * The poor performance of select() on large FD sets is avoided
86
+ as few file descriptors are used in each worker.
87
+ There should be no gain from moving to highly scalable but
88
+ unportable event notification solutions for watching few
89
+ file descriptors.
90
+
91
+ * If the master process dies unexpectedly for any reason,
92
+ workers will notice within :timeout/2 seconds and follow
93
+ the master to its death.
94
+
95
+ * There is never any explicit real-time dependency or communication
96
+ between the worker processes nor to the master process.
97
+ Synchronization is handled entirely by the OS kernel and shared
98
+ resources are never accessed by the worker when it is servicing
99
+ a client.
@@ -0,0 +1,3 @@
1
+ *.gz
2
+ *.html
3
+ *.txt
@@ -0,0 +1,222 @@
1
+ .TH "UNICORN" "1" "September 15, 2009" "Unicorn User Manual" ""
2
+ .hy
3
+ .SH NAME
4
+ .PP
5
+ unicorn \- a rackup\-like command to launch the Unicorn HTTP server
6
+ .SH SYNOPSIS
7
+ .PP
8
+ unicorn [\-c CONFIG_FILE] [\-E RACK_ENV] [\-D] [RACKUP_FILE]
9
+ .SH DESCRIPTION
10
+ .PP
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.
14
+ .PP
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.
19
+ .SH RACKUP FILE
20
+ .PP
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.
24
+ .PP
25
+ Embedded command\-line options are mostly parsed for compatibility
26
+ with rackup(1) but strongly discouraged.
27
+ .SH UNICORN OPTIONS
28
+ .TP
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
36
+ viewing ps(1) output.
37
+ .RS
38
+ .RE
39
+ .TP
40
+ .B \-D, \-\-daemonize
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
45
+ process.
46
+ Unless specified in the CONFIG_FILE, stderr and stdout will
47
+ also be redirected to "/dev/null".
48
+ .RS
49
+ .RE
50
+ .TP
51
+ .B \-E, \-\-env RACK_ENV
52
+ Run under the given RACK_ENV. See the RACK ENVIRONMENT section
53
+ for more details.
54
+ .RS
55
+ .RE
56
+ .TP
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
64
+ options.
65
+ .RS
66
+ .RE
67
+ .TP
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.
72
+ .RS
73
+ .RE
74
+ .SH RACKUP COMPATIBILITY OPTIONS
75
+ .TP
76
+ .B \-o, \-\-host HOST
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.
83
+ .RS
84
+ .RE
85
+ .TP
86
+ .B \-p, \-\-port PORT
87
+ Listen on the specified TCP PORT, default is 8080.
88
+ If specified multiple times on the command\-line, only the last\-specified
89
+ value takes effect.
90
+ This option only exists for compatibility with the rackup(1) command,
91
+ use of "\-l"/"\-\-listen" switch is recommended instead.
92
+ .RS
93
+ .RE
94
+ .TP
95
+ .B \-s, \-\-server SERVER
96
+ No\-op, this exists only for compatibility with rackup(1).
97
+ .RS
98
+ .RE
99
+ .SH RUBY OPTIONS
100
+ .TP
101
+ .B \-e, \-\-eval LINE
102
+ Evaluate a LINE of Ruby code. This evaluation happens
103
+ immediately as the command\-line is being parsed.
104
+ .RS
105
+ .RE
106
+ .TP
107
+ .B \-d, \-\-debug
108
+ Turn on debug mode, the $DEBUG variable is set to true.
109
+ .RS
110
+ .RE
111
+ .TP
112
+ .B \-w, \-\-warn
113
+ Turn on verbose warnings, the $VERBOSE variable is set to true.
114
+ .RS
115
+ .RE
116
+ .TP
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.
123
+ .RS
124
+ .RE
125
+ .TP
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.
130
+ .RS
131
+ .RE
132
+ .SH SIGNALS
133
+ .PP
134
+ The following UNIX signals may be sent to the master process:
135
+ .IP \[bu] 2
136
+ HUP \- reload config file, app, and gracefully restart all workers
137
+ .IP \[bu] 2
138
+ INT/TERM \- quick shutdown, kills all workers immediately
139
+ .IP \[bu] 2
140
+ QUIT \- graceful shutdown, waits for workers to finish their
141
+ current request before finishing.
142
+ .IP \[bu] 2
143
+ USR1 \- reopen all logs owned by the master and all workers
144
+ See Unicorn::Util.reopen_logs for what is considered a log.
145
+ .IP \[bu] 2
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
+ .IP \[bu] 2
150
+ WINCH \- gracefully stops workers but keep the master running.
151
+ This will only work for daemonized processes.
152
+ .IP \[bu] 2
153
+ TTIN \- increment the number of worker processes by one
154
+ .IP \[bu] 2
155
+ TTOU \- decrement the number of worker processes by one
156
+ .PP
157
+ See the SIGNALS (https://yhbt.net/unicorn/SIGNALS.html) document for
158
+ full description of all signals used by Unicorn.
159
+ .SH RACK ENVIRONMENT
160
+ .PP
161
+ Accepted values of RACK_ENV and the middleware they automatically load
162
+ (outside of RACKUP_FILE) are exactly as those in rackup(1):
163
+ .IP \[bu] 2
164
+ development \- loads Rack::CommonLogger, Rack::ShowExceptions, and
165
+ Rack::Lint middleware
166
+ .IP \[bu] 2
167
+ deployment \- loads Rack::CommonLogger middleware
168
+ .IP \[bu] 2
169
+ none \- loads no middleware at all, relying entirely on RACKUP_FILE
170
+ .PP
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.
174
+ .PP
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.
178
+ .PP
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
184
+ .PP
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.
192
+ .PP
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).
197
+ .PP
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.
202
+ .SH SEE ALSO
203
+ .IP \[bu] 2
204
+ \f[I]Rack::Builder\f[] ri/RDoc
205
+ .IP \[bu] 2
206
+ \f[I]Unicorn::Configurator\f[] ri/RDoc
207
+ .UR https://yhbt.net/unicorn/Unicorn/Configurator.html
208
+ .UE
209
+ .IP \[bu] 2
210
+ unicorn RDoc
211
+ .UR https://yhbt.net/unicorn/
212
+ .UE
213
+ .IP \[bu] 2
214
+ Rack RDoc
215
+ .UR https://www.rubydoc.info/github/rack/rack/
216
+ .UE
217
+ .IP \[bu] 2
218
+ Rackup HowTo
219
+ .UR https://github.com/rack/rack/wiki/(tutorial)-rackup-howto
220
+ .UE
221
+ .SH AUTHORS
222
+ The Unicorn Community <unicorn-public@yhbt.net>.
@@ -0,0 +1,207 @@
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
100
+ .RE
101
+ .SH RUBY OPTIONS
102
+ .TP
103
+ .B \-e, \-\-eval LINE
104
+ Evaluate a LINE of Ruby code. This evaluation happens
105
+ immediately as the command\-line is being parsed.
106
+ .RS
107
+ .RE
108
+ .TP
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.
113
+ .RS
114
+ .RE
115
+ .TP
116
+ .B \-w, \-\-warn
117
+ Turn on verbose warnings, the $VERBOSE variable is set to true.
118
+ .RS
119
+ .RE
120
+ .TP
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.
127
+ .RS
128
+ .RE
129
+ .TP
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.
134
+ .RS
135
+ .RE
136
+ .SH RACKUP FILE
137
+ .PP
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.
143
+ .PP
144
+ Embedded command\-line options are mostly parsed for compatibility
145
+ with rackup(1) but strongly discouraged.
146
+ .SH ENVIRONMENT VARIABLES
147
+ .PP
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
159
+ .PP
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
182
+ .PP
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
193
+ .UE
194
+ .IP \[bu] 2
195
+ unicorn RDoc
196
+ .UR https://yhbt.net/unicorn/
197
+ .UE
198
+ .IP \[bu] 2
199
+ Rack RDoc
200
+ .UR https://www.rubydoc.info/github/rack/rack/
201
+ .UE
202
+ .IP \[bu] 2
203
+ Rackup HowTo
204
+ .UR https://github.com/rack/rack/wiki/(tutorial)-rackup-howto
205
+ .UE
206
+ .SH AUTHORS
207
+ The Unicorn Community <unicorn-public@yhbt.net>.
data/FAQ ADDED
@@ -0,0 +1,70 @@
1
+ = Frequently Asked Questions about Unicorn
2
+
3
+ === Why is nginx getting ECONNRESET as a reverse proxy?
4
+
5
+ Request body data (commonly from POST and PUT requests) may not be
6
+ drained entirely by the application. This may happen when request
7
+ bodies are gzipped, as unicorn reads request body data lazily to avoid
8
+ overhead from bad requests.
9
+
10
+ Ref: https://yhbt.net/unicorn-public/FC91211E-FD32-432C-92FC-0318714C2170@zendesk.com/
11
+
12
+ === Why aren't my Rails log files rotated when I use SIGUSR1?
13
+
14
+ The Rails autoflush_log option must remain disabled with multiprocess
15
+ servers such as unicorn. Buffering in userspace may cause lines to be
16
+ partially written and lead to corruption in the presence of multiple
17
+ processes. With reasonable amounts of logging, the performance impact
18
+ of autoflush_log should be negligible on Linux and other modern kernels.
19
+
20
+ === Why are my redirects going to "http" URLs when my site uses https?
21
+
22
+ If your site is entirely behind https, then Rack applications that use
23
+ "rack.url_scheme" can set the following in the Unicorn config file:
24
+
25
+ HttpRequest::DEFAULTS["rack.url_scheme"] = "https"
26
+
27
+ For frameworks that do not use "rack.url_scheme", you can also
28
+ try setting one or both of the following:
29
+
30
+ HttpRequest::DEFAULTS["HTTPS"] = "on"
31
+ HttpRequest::DEFAULTS["HTTP_X_FORWARDED_PROTO"] = "https"
32
+
33
+ Otherwise, you can configure your proxy (nginx) to send the
34
+ "X-Forwarded-Proto: https" header only for parts of the site that use
35
+ https. For nginx, you can do it with the following line in appropriate
36
+ "location" blocks of your nginx config file:
37
+
38
+ proxy_set_header X-Forwarded-Proto https;
39
+
40
+ === Why are log messages from Unicorn are unformatted when using Rails?
41
+
42
+ Current versions of Rails unfortunately overrides the default Logger
43
+ formatter.
44
+
45
+ You can undo this behavior with the default logger in your Unicorn
46
+ config file:
47
+
48
+ Configurator::DEFAULTS[:logger].formatter = Logger::Formatter.new
49
+
50
+ Of course you can specify an entirely different logger as well
51
+ with the "logger" directive described by Unicorn::Configurator.
52
+
53
+ === Why am I getting "connection refused"/502 errors under high load?
54
+
55
+ Short answer: your application cannot keep up.
56
+
57
+ You can increase the size of the :backlog parameter if your kernel
58
+ supports a larger listen() queue, but keep in mind having a large listen
59
+ queue makes failover to a different machine more difficult.
60
+
61
+ See the TUNING and Unicorn::Configurator documents for more information
62
+ on :backlog-related topics.
63
+
64
+ === I've installed Rack 1.1.x, why can't Unicorn load Rails (2.3.5)?
65
+
66
+ Rails 2.3.5 is not compatible with Rack 1.1.x. Unicorn is compatible
67
+ with both Rack 1.1.x and Rack 1.0.x, and RubyGems will load the latest
68
+ version of Rack installed on the system. Uninstalling the Rack 1.1.x
69
+ gem should solve gem loading issues with Rails 2.3.5. Rails 2.3.6
70
+ and later correctly support Rack 1.1.x.
data/GIT-VERSION-FILE ADDED
@@ -0,0 +1 @@
1
+ GIT_VERSION = 6.1.0.68.ge9862.dirty
data/GIT-VERSION-GEN ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ DEF_VER = "v6.1.0"
3
+ CONSTANT = "Unicorn::Const::UNICORN_VERSION"
4
+ RVF = "lib/unicorn/version.rb"
5
+ GVF = "GIT-VERSION-FILE"
6
+ vn = DEF_VER
7
+
8
+ # First see if there is a version file (included in release tarballs),
9
+ # then try git-describe, then default.
10
+ if File.exist?(".git")
11
+ describe = `git describe --abbrev=4 HEAD 2>/dev/null`.strip
12
+ case describe
13
+ when /\Av[0-9]*/
14
+ vn = describe
15
+ system(*%w(git update-index -q --refresh))
16
+ unless `git diff-index --name-only HEAD --`.chomp.empty?
17
+ vn << "-dirty"
18
+ end
19
+ vn.tr!('-', '.')
20
+ end
21
+ end
22
+
23
+ vn = vn.sub!(/\Av/, "")
24
+
25
+ # generate the Ruby constant
26
+ new_ruby_version = "#{CONSTANT} = '#{vn}'\n"
27
+ cur_ruby_version = File.read(RVF) rescue nil
28
+ if new_ruby_version != cur_ruby_version
29
+ File.open(RVF, "w") { |fp| fp.write(new_ruby_version) }
30
+ end
31
+
32
+ # generate the makefile snippet
33
+ new_make_version = "GIT_VERSION = #{vn}\n"
34
+ cur_make_version = File.read(GVF) rescue nil
35
+ if new_make_version != cur_make_version
36
+ File.open(GVF, "w") { |fp| fp.write(new_make_version) }
37
+ end
38
+
39
+ puts vn if $0 == __FILE__