rainbows 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +1 -0
- data/COPYING +617 -282
- data/Documentation/comparison.haml +81 -24
- data/FAQ +3 -0
- data/GIT-VERSION-GEN +1 -1
- data/LICENSE +14 -5
- data/README +10 -9
- data/Sandbox +25 -0
- data/TODO +2 -22
- data/lib/rainbows.rb +50 -49
- data/lib/rainbows/client.rb +6 -5
- data/lib/rainbows/configurator.rb +191 -37
- data/lib/rainbows/const.rb +1 -1
- data/lib/rainbows/coolio.rb +4 -1
- data/lib/rainbows/coolio/client.rb +2 -2
- data/lib/rainbows/coolio/heartbeat.rb +2 -1
- data/lib/rainbows/coolio_fiber_spawn.rb +12 -7
- data/lib/rainbows/coolio_thread_pool.rb +19 -10
- data/lib/rainbows/coolio_thread_spawn.rb +3 -0
- data/lib/rainbows/epoll.rb +27 -5
- data/lib/rainbows/epoll/client.rb +3 -3
- data/lib/rainbows/ev_core.rb +2 -1
- data/lib/rainbows/event_machine.rb +4 -0
- data/lib/rainbows/event_machine/client.rb +2 -1
- data/lib/rainbows/fiber.rb +5 -0
- data/lib/rainbows/fiber/base.rb +1 -0
- data/lib/rainbows/fiber/coolio/methods.rb +0 -1
- data/lib/rainbows/fiber/io.rb +10 -6
- data/lib/rainbows/fiber/io/pipe.rb +6 -1
- data/lib/rainbows/fiber/io/socket.rb +6 -1
- data/lib/rainbows/fiber_pool.rb +12 -7
- data/lib/rainbows/fiber_spawn.rb +11 -6
- data/lib/rainbows/http_server.rb +55 -59
- data/lib/rainbows/join_threads.rb +4 -0
- data/lib/rainbows/max_body.rb +29 -10
- data/lib/rainbows/never_block.rb +7 -10
- data/lib/rainbows/pool_size.rb +14 -0
- data/lib/rainbows/process_client.rb +23 -1
- data/lib/rainbows/queue_pool.rb +8 -6
- data/lib/rainbows/response.rb +12 -11
- data/lib/rainbows/revactor.rb +14 -7
- data/lib/rainbows/revactor/client.rb +2 -2
- data/lib/rainbows/stream_file.rb +11 -4
- data/lib/rainbows/thread_pool.rb +12 -28
- data/lib/rainbows/thread_spawn.rb +14 -13
- data/lib/rainbows/thread_timeout.rb +118 -30
- data/lib/rainbows/writer_thread_pool/client.rb +1 -1
- data/lib/rainbows/writer_thread_spawn/client.rb +2 -2
- data/lib/rainbows/xepoll.rb +13 -5
- data/lib/rainbows/xepoll/client.rb +19 -17
- data/lib/rainbows/xepoll_thread_pool.rb +82 -0
- data/lib/rainbows/xepoll_thread_pool/client.rb +129 -0
- data/lib/rainbows/xepoll_thread_spawn.rb +58 -0
- data/lib/rainbows/xepoll_thread_spawn/client.rb +121 -0
- data/pkg.mk +4 -0
- data/rainbows.gemspec +4 -1
- data/t/GNUmakefile +5 -1
- data/t/client_header_buffer_size.ru +5 -0
- data/t/simple-http_XEpollThreadPool.ru +10 -0
- data/t/simple-http_XEpollThreadSpawn.ru +10 -0
- data/t/t0022-copy_stream-byte-range.sh +1 -15
- data/t/t0026-splice-copy_stream-byte-range.sh +25 -0
- data/t/t0027-nil-copy_stream.sh +60 -0
- data/t/t0041-optional-pool-size.sh +2 -2
- data/t/t0042-client_header_buffer_size.sh +65 -0
- data/t/t9100-thread-timeout.sh +1 -6
- data/t/t9101-thread-timeout-threshold.sh +1 -6
- data/t/test-lib.sh +58 -0
- data/t/test_isolate.rb +9 -3
- metadata +47 -16
@@ -33,7 +33,7 @@
|
|
33
33
|
%td.r18 Yes
|
34
34
|
%td.r19 Yes
|
35
35
|
%td.rbx Yes
|
36
|
-
%td.slow
|
36
|
+
%td.slow Yes
|
37
37
|
%tr.comp_row
|
38
38
|
%td.mod Coolio
|
39
39
|
%td.tee No
|
@@ -47,7 +47,7 @@
|
|
47
47
|
%td.r18 Yes
|
48
48
|
%td.r19 Yes
|
49
49
|
%td.rbx Yes
|
50
|
-
%td.slow
|
50
|
+
%td.slow Yes
|
51
51
|
%tr.comp_row
|
52
52
|
%td.mod EventMachine
|
53
53
|
%td.tee No
|
@@ -118,6 +118,34 @@
|
|
118
118
|
%td.r19 Yes
|
119
119
|
%td.rbx Yes
|
120
120
|
%td.slow no
|
121
|
+
%tr.comp_row
|
122
|
+
%td.mod Epoll
|
123
|
+
%td.tee no
|
124
|
+
%td.r18 Yes
|
125
|
+
%td.r19 Yes
|
126
|
+
%td.rbx Yes
|
127
|
+
%td.slow Yes
|
128
|
+
%tr.comp_row
|
129
|
+
%td.mod XEpoll
|
130
|
+
%td.tee no
|
131
|
+
%td.r18 Yes
|
132
|
+
%td.r19 Yes
|
133
|
+
%td.rbx Yes
|
134
|
+
%td.slow Yes
|
135
|
+
%tr.comp_row
|
136
|
+
%td.mod XEpollThreadSpawn
|
137
|
+
%td.tee Yes
|
138
|
+
%td.r18 Yes
|
139
|
+
%td.r19 Yes
|
140
|
+
%td.rbx Yes
|
141
|
+
%td.slow Yes
|
142
|
+
%tr.comp_row
|
143
|
+
%td.mod XEpollThreadPool
|
144
|
+
%td.tee Yes
|
145
|
+
%td.r18 Yes
|
146
|
+
%td.r19 Yes
|
147
|
+
%td.rbx Yes
|
148
|
+
%td.slow Yes
|
121
149
|
%ul
|
122
150
|
%li
|
123
151
|
Cool.io should also work with Rubinius (though we haven't had time to test).
|
@@ -232,6 +260,26 @@
|
|
232
260
|
%td.slowio avoid
|
233
261
|
%td.thr Maybe
|
234
262
|
%td.reent Maybe
|
263
|
+
%tr.comp_base
|
264
|
+
%td.mod Epoll
|
265
|
+
%td.slowio No
|
266
|
+
%td.thr No
|
267
|
+
%td.reent No
|
268
|
+
%tr.comp_base
|
269
|
+
%td.mod XEpoll
|
270
|
+
%td.slowio No
|
271
|
+
%td.thr No
|
272
|
+
%td.reent No
|
273
|
+
%tr.comp_base
|
274
|
+
%td.mod XEpollThreadSpawn
|
275
|
+
%td.slowio thread-safe Ruby
|
276
|
+
%td.thr Yes
|
277
|
+
%td.reent No
|
278
|
+
%tr.comp_base
|
279
|
+
%td.mod XEpollThreadPool
|
280
|
+
%td.slowio thread-safe Ruby
|
281
|
+
%td.thr Yes
|
282
|
+
%td.reent No
|
235
283
|
%ul
|
236
284
|
%li
|
237
285
|
Requirements for single thread reentrancy are loose in that there is
|
@@ -264,91 +312,78 @@
|
|
264
312
|
%th.lock
|
265
313
|
%a(href="http://rack.rubyforge.org/doc/Rack/Lock.html") Rack::Lock
|
266
314
|
%th.async async
|
267
|
-
%th.ws Web Sockets
|
268
315
|
%tr.comp_row
|
269
316
|
%td.mod Unicorn/Base
|
270
317
|
%td.devfd no-op
|
271
318
|
%td.app_pool no-op
|
272
319
|
%td.lock no-op
|
273
320
|
%td.async lots of RAM :P
|
274
|
-
%td.ws no
|
275
321
|
%tr.comp_row
|
276
322
|
%td.mod Revactor
|
277
323
|
%td.devfd no-op
|
278
324
|
%td.app_pool Yes
|
279
325
|
%td.lock No!
|
280
326
|
%td.async Revactor itself
|
281
|
-
%td.ws no
|
282
327
|
%tr.comp_row
|
283
328
|
%td.mod ThreadPool
|
284
329
|
%td.devfd Yes
|
285
330
|
%td.app_pool Yes
|
286
331
|
%td.lock Yes
|
287
|
-
%td.async
|
288
|
-
%td.ws no
|
332
|
+
%td.async thread-safe Ruby
|
289
333
|
%tr.comp_row
|
290
334
|
%td.mod Coolio
|
291
335
|
%td.devfd Yes
|
292
336
|
%td.app_pool no-op
|
293
337
|
%td.lock no-op
|
294
338
|
%td.async DevFdResponse
|
295
|
-
%td.ws no
|
296
339
|
%tr.comp_row
|
297
340
|
%td.mod ThreadSpawn
|
298
341
|
%td.devfd Yes
|
299
342
|
%td.app_pool Yes
|
300
343
|
%td.lock Yes
|
301
|
-
%td.async
|
302
|
-
%td.ws no
|
344
|
+
%td.async thread-safe Ruby
|
303
345
|
%tr.comp_row
|
304
346
|
%td.mod EventMachine
|
305
347
|
%td.devfd Yes
|
306
348
|
%td.app_pool no-op
|
307
349
|
%td.lock no-op
|
308
350
|
%td.async async_sinatra, Cramp, rack-fiber_pool
|
309
|
-
%td.ws no
|
310
351
|
%tr.comp_row
|
311
352
|
%td.mod CoolioThreadSpawn
|
312
353
|
%td.devfd Yes
|
313
354
|
%td.app_pool Yes
|
314
355
|
%td.lock Dumb
|
315
|
-
%td.async
|
316
|
-
%td.ws no
|
356
|
+
%td.async thread-safe Ruby
|
317
357
|
%tr.comp_row
|
318
358
|
%td.mod FiberSpawn
|
319
359
|
%td.devfd Yes
|
320
360
|
%td.app_pool Yes
|
321
361
|
%td.lock No!
|
322
362
|
%td.async Rainbows::Fiber::IO, Rainbows.sleep
|
323
|
-
%td.ws no
|
324
363
|
%tr.comp_row
|
325
364
|
%td.mod FiberPool
|
326
365
|
%td.devfd Yes
|
327
366
|
%td.app_pool Yes
|
328
367
|
%td.lock No!
|
329
368
|
%td.async Rainbows::Fiber::IO, Rainbows.sleep
|
330
|
-
%td.ws no
|
331
369
|
%tr.comp_row
|
332
370
|
%td.mod ActorSpawn
|
333
371
|
%td.devfd no-op
|
334
372
|
%td.app_pool Yes
|
335
373
|
%td.lock Yes
|
336
|
-
%td.async
|
337
|
-
%td.ws no
|
374
|
+
%td.async thread-safe Ruby
|
338
375
|
%tr.comp_row
|
339
376
|
%td.mod NeverBlock
|
340
377
|
%td.devfd Yes
|
341
378
|
%td.app_pool Yes*
|
342
379
|
%td.lock Yes*
|
343
380
|
%td.async NeverBlock, async_sinatra
|
344
|
-
%td.ws no
|
345
381
|
%tr.comp_row
|
346
382
|
%td.mod CoolioThreadPool
|
347
383
|
%td.devfd Yes
|
348
384
|
%td.app_pool Yes
|
349
385
|
%td.lock Dumb
|
350
|
-
%td.async Coolio,
|
351
|
-
%td.ws no
|
386
|
+
%td.async Coolio, thread-safe Ruby
|
352
387
|
%tr.comp_row
|
353
388
|
%td.mod CoolioFiberSpawn
|
354
389
|
%td.devfd Yes
|
@@ -360,15 +395,37 @@
|
|
360
395
|
%td.devfd Yes
|
361
396
|
%td.app_pool no-op
|
362
397
|
%td.lock no-op
|
363
|
-
%td.async
|
364
|
-
%td.ws response body only
|
398
|
+
%td.async thread-safe Ruby in response body only
|
365
399
|
%tr.comp_row
|
366
400
|
%td.mod WriterThreadSpawn
|
367
401
|
%td.devfd Yes
|
368
402
|
%td.app_pool no-op
|
369
403
|
%td.lock no-op
|
370
|
-
%td.async
|
371
|
-
|
404
|
+
%td.async thread-safe Ruby in response body only
|
405
|
+
%tr.comp_row
|
406
|
+
%td.mod Epoll
|
407
|
+
%td.devfd Yes
|
408
|
+
%td.app_pool no-op
|
409
|
+
%td.lock no-op
|
410
|
+
%td.async DevFdResponse
|
411
|
+
%tr.comp_row
|
412
|
+
%td.mod XEpoll
|
413
|
+
%td.devfd Yes
|
414
|
+
%td.app_pool no-op
|
415
|
+
%td.lock no-op
|
416
|
+
%td.async DevFdResponse
|
417
|
+
%tr.comp_row
|
418
|
+
%td.mod XEpollThreadPool
|
419
|
+
%td.devfd Yes
|
420
|
+
%td.app_pool Yes
|
421
|
+
%td.lock Yes
|
422
|
+
%td.async thread-safe Ruby
|
423
|
+
%tr.comp_row
|
424
|
+
%td.mod XEpollThreadSpawn
|
425
|
+
%td.devfd Yes
|
426
|
+
%td.app_pool Yes
|
427
|
+
%td.lock Yes
|
428
|
+
%td.async thread-safe Ruby
|
372
429
|
%ul
|
373
430
|
%li
|
374
431
|
"No!" means it's fundamentally incompatible, use an
|
data/FAQ
CHANGED
@@ -18,6 +18,9 @@ requests we service.
|
|
18
18
|
=== Isn't "rainbows" a branch of Unicorn?
|
19
19
|
|
20
20
|
That functionality is now in the Revactor model of \Rainbows!
|
21
|
+
However, \Revactor is not recommended since it is dormant
|
22
|
+
upstream and requires your application (and all its libraries)
|
23
|
+
to cooperate with \Revactor for concurrency.
|
21
24
|
|
22
25
|
|
23
26
|
=== What happened to the "gossamer" branch of Unicorn?
|
data/GIT-VERSION-GEN
CHANGED
data/LICENSE
CHANGED
@@ -1,8 +1,17 @@
|
|
1
|
-
\Rainbows! is copyrighted Free Software by all contributors, see the
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
the
|
1
|
+
\Rainbows! is copyrighted Free Software by all contributors, see the logs in
|
2
|
+
revision control for names and email addresses of all of them.
|
3
|
+
|
4
|
+
You can redistribute it and/or modify it under either the terms of the
|
5
|
+
GNU General Public License (GPL) as published by the Free Software
|
6
|
+
Foundation (FSF), version {3.0}[http://www.gnu.org/licenses/gpl-3.0.txt]
|
7
|
+
or version {2.0}[http://www.gnu.org/licenses/gpl-2.0.txt]
|
8
|
+
or the Ruby-specific license terms (see below).
|
9
|
+
|
10
|
+
The \Rainbows! project leader (Eric Wong) reserves the right to add future
|
11
|
+
versions of the GPL (and no other licenses) as published by the FSF to
|
12
|
+
the licensing terms.
|
13
|
+
|
14
|
+
=== Ruby-specific terms (if you're not using the GPLv2/GPLv3)
|
6
15
|
|
7
16
|
1. You may make and give away verbatim copies of the source form of the
|
8
17
|
software without restriction, provided that you duplicate all of the
|
data/README
CHANGED
@@ -22,18 +22,22 @@ suck; differently.
|
|
22
22
|
For network concurrency, models we currently support are:
|
23
23
|
|
24
24
|
* {Coolio}[link:Rainbows/Coolio.html]
|
25
|
+
* {CoolioFiberSpawn}[link:Rainbows/CoolioFiberSpawn.html]
|
26
|
+
* {CoolioThreadPool}[link:Rainbows/CoolioThreadPool.html]
|
27
|
+
* {CoolioThreadSpawn}[link:Rainbows/CoolioThreadSpawn.html]
|
28
|
+
* {Epoll}[link:Rainbows/Epoll.html]
|
25
29
|
* {EventMachine}[link:Rainbows/EventMachine.html]
|
26
|
-
* {FiberSpawn}[link:Rainbows/FiberSpawn.html]
|
27
30
|
* {FiberPool}[link:Rainbows/FiberPool.html]
|
31
|
+
* {FiberSpawn}[link:Rainbows/FiberSpawn.html]
|
28
32
|
* {NeverBlock}[link:Rainbows/NeverBlock.html]
|
29
33
|
* {Revactor}[link:Rainbows/Revactor.html]
|
30
34
|
* {ThreadPool}[link:Rainbows/ThreadPool.html]
|
31
35
|
* {ThreadSpawn}[link:Rainbows/ThreadSpawn.html]
|
32
36
|
* {WriterThreadPool}[link:Rainbows/WriterThreadPool.html]
|
33
37
|
* {WriterThreadSpawn}[link:Rainbows/WriterThreadSpawn.html]
|
34
|
-
* {
|
35
|
-
* {
|
36
|
-
* {
|
38
|
+
* {XEpoll}[link:Rainbows/XEpoll.html]
|
39
|
+
* {XEpollThreadPool}[link:Rainbows/XEpollThreadPool.html]
|
40
|
+
* {XEpollThreadSpawn}[link:Rainbows/XEpollThreadSpawn.html]
|
37
41
|
|
38
42
|
We have {many more on the way}[link:TODO.html] for handling network
|
39
43
|
concurrency. Additionally, we also use multiple processes (managed by
|
@@ -86,11 +90,8 @@ fast applications.
|
|
86
90
|
== License
|
87
91
|
|
88
92
|
\Rainbows! is copyright 2009,2010 by all contributors (see logs in git).
|
89
|
-
|
90
|
-
|
91
|
-
Mongrel is copyright 2007 Zed A. Shaw and contributors. It is licensed
|
92
|
-
under the Ruby (1.8) license and the GPL2. See the included LICENSE file for
|
93
|
-
details.
|
93
|
+
\Rainbows! is licensed under the Ruby (1.8) license or the GPL (v2 or v3).
|
94
|
+
See the included {LICENSE}[link:LICENSE.html] file for more details.
|
94
95
|
|
95
96
|
\Rainbows! is 100% Free Software.
|
96
97
|
|
data/Sandbox
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
= Tips for using \Rainbows! with Sandbox installation tools
|
2
|
+
|
3
|
+
Most {tips for Unicorn}[http://unicorn.bogomips.org/Sandbox.html]
|
4
|
+
for Bundler and Isolate apply to \Rainbows! as well.
|
5
|
+
|
6
|
+
== TLDR (Bundler)
|
7
|
+
|
8
|
+
You need to add "rainbows" to your Gemfile for Bundler and start
|
9
|
+
\Rainbows! with:
|
10
|
+
|
11
|
+
bundle exec rainbows ...
|
12
|
+
|
13
|
+
== TLDR (Isolate)
|
14
|
+
|
15
|
+
Isolate "rainbows" and execute the "rainbows" launcher in your isolated
|
16
|
+
GEM_PATH:
|
17
|
+
|
18
|
+
$APP_ROOT/tmp/ruby-1.9/bin/rainbows ...
|
19
|
+
|
20
|
+
== Explanation
|
21
|
+
|
22
|
+
Due to the variety of potential dependencies, \Rainbows! lazy loads many
|
23
|
+
of its internals, often after the application itself is loaded. This
|
24
|
+
results in more potential to interact badly with sandbox tools that
|
25
|
+
modify the gem environment.
|
data/TODO
CHANGED
@@ -3,35 +3,15 @@
|
|
3
3
|
We're lazy and pick the easy items to do first, then the ones people
|
4
4
|
care about.
|
5
5
|
|
6
|
-
*
|
6
|
+
* investigate non-Rack frameworks (e.g. Goliath)
|
7
7
|
|
8
|
-
*
|
9
|
-
NeverBlock will default to one of them (depending on NB upstream).
|
8
|
+
* documentation improvements
|
10
9
|
|
11
10
|
* allow _OPTIONAL_ splice(2) with DevFdResponse under Linux
|
12
11
|
(splice is very broken under some older kernels)
|
13
12
|
|
14
|
-
* use IO#trysendfile for EventMachine/NeverBlock
|
15
|
-
|
16
|
-
* Open file cache Rack app/middleware (idea from nginx), since sendfile
|
17
|
-
(and IO.copy_stream) allows pread(2)-style offsets
|
18
|
-
|
19
13
|
* Improve test suite coverage. We won't waste cycles with puny
|
20
14
|
unit tests, only integration tests that exercise externally
|
21
15
|
visible parts.
|
22
16
|
|
23
|
-
* EventMachine+Fibers+streaming input
|
24
|
-
(those who do not require streaming input can use
|
25
|
-
{rack-fiber_pool}[http://github.com/mperham/rack-fiber_pool])
|
26
|
-
|
27
|
-
* CoolioFiberPool
|
28
|
-
|
29
|
-
* ThreadPoolRevFiber{Spawn,Pool}: just because
|
30
|
-
|
31
|
-
* Coolio + callcc - current Coolio model with callcc (should work with MBARI)
|
32
|
-
|
33
|
-
* Omnibus - haven't looked into it, probably like Revactor with 1.8?
|
34
|
-
|
35
|
-
* Packet - pure Ruby, EventMachine-like library
|
36
|
-
|
37
17
|
* test and improve performance (throughput/latency/memory usage)
|
data/lib/rainbows.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# -*- encoding: binary -*-
|
2
2
|
require 'kgio'
|
3
3
|
require 'unicorn'
|
4
|
+
require 'io/wait'
|
4
5
|
Unicorn::SocketHelper::DEFAULTS.merge!({
|
5
6
|
# the value passed to TCP_DEFER_ACCEPT actually matters in Linux 2.6.32+
|
6
7
|
:tcp_defer_accept => 60,
|
@@ -15,17 +16,16 @@ Unicorn::SocketHelper::DEFAULTS.merge!({
|
|
15
16
|
:tcp_nopush => false,
|
16
17
|
})
|
17
18
|
|
19
|
+
# See http://rainbows.rubyforge.org/ for documentation
|
18
20
|
module Rainbows
|
19
|
-
|
20
|
-
O = {}
|
21
|
+
# :stopdoc:
|
22
|
+
O = {}
|
21
23
|
|
22
24
|
# map of numeric file descriptors to IO objects to avoid using IO.new
|
23
25
|
# and potentially causing race conditions when using /dev/fd/
|
24
26
|
FD_MAP = {}
|
25
27
|
FD_MAP.compare_by_identity if FD_MAP.respond_to?(:compare_by_identity)
|
26
28
|
|
27
|
-
# :startdoc:
|
28
|
-
|
29
29
|
require 'rainbows/const'
|
30
30
|
require 'rainbows/http_parser'
|
31
31
|
require 'rainbows/http_server'
|
@@ -41,23 +41,25 @@ module Rainbows
|
|
41
41
|
autoload :EvCore, 'rainbows/ev_core'
|
42
42
|
autoload :SocketProxy, 'rainbows/socket_proxy'
|
43
43
|
|
44
|
+
# :startdoc:
|
44
45
|
# Sleeps the current application dispatch. This will pick the
|
45
46
|
# optimal method to sleep depending on the concurrency model chosen
|
46
47
|
# (which may still suck and block the entire process). Using this
|
47
48
|
# with the basic :Coolio or :EventMachine models is not recommended.
|
48
49
|
# This should be used within your Rack application.
|
49
|
-
def self.sleep(
|
50
|
+
def self.sleep(seconds)
|
50
51
|
case Rainbows.server.use
|
51
52
|
when :FiberPool, :FiberSpawn
|
52
|
-
Rainbows::Fiber.sleep(
|
53
|
+
Rainbows::Fiber.sleep(seconds)
|
53
54
|
when :RevFiberSpawn, :CoolioFiberSpawn
|
54
|
-
Rainbows::Fiber::Coolio::Sleeper.new(
|
55
|
+
Rainbows::Fiber::Coolio::Sleeper.new(seconds)
|
55
56
|
when :Revactor
|
56
|
-
Actor.sleep(
|
57
|
+
Actor.sleep(seconds)
|
57
58
|
else
|
58
|
-
Kernel.sleep(
|
59
|
+
Kernel.sleep(seconds)
|
59
60
|
end
|
60
61
|
end
|
62
|
+
# :stopdoc:
|
61
63
|
|
62
64
|
# runs the Rainbows! HttpServer with +app+ and +options+ and does
|
63
65
|
# not return until the server has exited.
|
@@ -65,27 +67,30 @@ module Rainbows
|
|
65
67
|
HttpServer.new(app, options).start.join
|
66
68
|
end
|
67
69
|
|
68
|
-
# :stopdoc:
|
69
70
|
class << self
|
70
|
-
attr_accessor :max_bytes, :keepalive_timeout
|
71
71
|
attr_accessor :server
|
72
72
|
attr_accessor :cur # may not always be used
|
73
73
|
attr_reader :alive
|
74
74
|
attr_writer :tick_io
|
75
|
+
attr_writer :forked
|
75
76
|
end
|
76
|
-
# :startdoc:
|
77
|
-
|
78
|
-
# the default max body size is 1 megabyte (1024 * 1024 bytes)
|
79
|
-
@max_bytes = 1024 * 1024
|
80
77
|
|
81
|
-
|
82
|
-
|
78
|
+
def self.config!(mod, *opts)
|
79
|
+
@forked or abort "#{mod} should only be loaded in a worker process"
|
80
|
+
opts.each do |opt|
|
81
|
+
mod.const_set(opt.to_s.upcase, Rainbows.server.__send__(opt))
|
82
|
+
end
|
83
|
+
end
|
83
84
|
|
84
|
-
# :stopdoc:
|
85
85
|
@alive = true
|
86
86
|
@cur = 0
|
87
87
|
@tick_mod = 0
|
88
88
|
@expire = nil
|
89
|
+
@at_quit = []
|
90
|
+
|
91
|
+
def self.at_quit(&block)
|
92
|
+
@at_quit << block
|
93
|
+
end
|
89
94
|
|
90
95
|
def self.tick
|
91
96
|
@tick_io.chmod(@tick_mod = 0 == @tick_mod ? 1 : 0)
|
@@ -102,41 +107,36 @@ module Rainbows
|
|
102
107
|
@alive = false
|
103
108
|
Rainbows::HttpParser.quit
|
104
109
|
@expire = Time.now + (@server.timeout * 2.0)
|
105
|
-
|
110
|
+
Unicorn::HttpServer::LISTENERS.each { |s| s.close rescue nil }.clear
|
111
|
+
@at_quit.each { |task| task.call }
|
106
112
|
end
|
107
113
|
false
|
108
114
|
end
|
109
115
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
:NeverBlock => 50,
|
135
|
-
}.each do |model, _|
|
136
|
-
u = model.to_s.gsub(/([a-z0-9])([A-Z0-9])/) { "#{$1}_#{$2.downcase!}" }
|
137
|
-
autoload model, "rainbows/#{u.downcase!}"
|
138
|
-
end
|
139
|
-
# :startdoc:
|
116
|
+
autoload :Base, "rainbows/base"
|
117
|
+
autoload :WriterThreadPool, "rainbows/writer_thread_pool"
|
118
|
+
autoload :WriterThreadSpawn, "rainbows/writer_thread_spawn"
|
119
|
+
autoload :Revactor, "rainbows/revactor"
|
120
|
+
autoload :ThreadSpawn, "rainbows/thread_spawn"
|
121
|
+
autoload :ThreadPool, "rainbows/thread_pool"
|
122
|
+
autoload :Rev, "rainbows/rev"
|
123
|
+
autoload :RevThreadSpawn, "rainbows/rev_thread_spawn"
|
124
|
+
autoload :RevThreadPool, "rainbows/rev_thread_pool"
|
125
|
+
autoload :RevFiberSpawn, "rainbows/rev_fiber_spawn"
|
126
|
+
autoload :Coolio, "rainbows/coolio"
|
127
|
+
autoload :CoolioThreadSpawn, "rainbows/coolio_thread_spawn"
|
128
|
+
autoload :CoolioThreadPool, "rainbows/coolio_thread_pool"
|
129
|
+
autoload :CoolioFiberSpawn, "rainbows/coolio_fiber_spawn"
|
130
|
+
autoload :Epoll, "rainbows/epoll"
|
131
|
+
autoload :XEpoll, "rainbows/xepoll"
|
132
|
+
autoload :EventMachine, "rainbows/event_machine"
|
133
|
+
autoload :FiberSpawn, "rainbows/fiber_spawn"
|
134
|
+
autoload :FiberPool, "rainbows/fiber_pool"
|
135
|
+
autoload :ActorSpawn, "rainbows/actor_spawn"
|
136
|
+
autoload :NeverBlock, "rainbows/never_block"
|
137
|
+
autoload :XEpollThreadSpawn, "rainbows/xepoll_thread_spawn"
|
138
|
+
autoload :XEpollThreadPool, "rainbows/xepoll_thread_pool"
|
139
|
+
|
140
140
|
autoload :Fiber, 'rainbows/fiber' # core class
|
141
141
|
autoload :StreamFile, 'rainbows/stream_file'
|
142
142
|
autoload :HttpResponse, 'rainbows/http_response' # deprecated
|
@@ -145,6 +145,7 @@ module Rainbows
|
|
145
145
|
autoload :SyncClose, 'rainbows/sync_close'
|
146
146
|
autoload :ReverseProxy, 'rainbows/reverse_proxy'
|
147
147
|
autoload :JoinThreads, 'rainbows/join_threads'
|
148
|
+
autoload :PoolSize, 'rainbows/pool_size'
|
148
149
|
end
|
149
150
|
|
150
151
|
require 'rainbows/error'
|