raindrops-maintained 0.21.0

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 (64) hide show
  1. checksums.yaml +7 -0
  2. data/.document +7 -0
  3. data/.gitattributes +4 -0
  4. data/.gitignore +16 -0
  5. data/.manifest +62 -0
  6. data/.olddoc.yml +16 -0
  7. data/COPYING +165 -0
  8. data/GIT-VERSION-FILE +1 -0
  9. data/GIT-VERSION-GEN +40 -0
  10. data/GNUmakefile +4 -0
  11. data/LATEST +9 -0
  12. data/LICENSE +16 -0
  13. data/NEWS +384 -0
  14. data/README +101 -0
  15. data/TODO +3 -0
  16. data/archive/.gitignore +3 -0
  17. data/archive/slrnpull.conf +4 -0
  18. data/examples/linux-listener-stats.rb +122 -0
  19. data/examples/middleware.ru +5 -0
  20. data/examples/watcher.ru +4 -0
  21. data/examples/watcher_demo.ru +13 -0
  22. data/examples/yahns.conf.rb +30 -0
  23. data/examples/zbatery.conf.rb +16 -0
  24. data/ext/raindrops/extconf.rb +163 -0
  25. data/ext/raindrops/linux_inet_diag.c +713 -0
  26. data/ext/raindrops/my_fileno.h +16 -0
  27. data/ext/raindrops/raindrops.c +487 -0
  28. data/ext/raindrops/raindrops_atomic.h +23 -0
  29. data/ext/raindrops/tcp_info.c +245 -0
  30. data/lib/raindrops/aggregate/last_data_recv.rb +94 -0
  31. data/lib/raindrops/aggregate/pmq.rb +245 -0
  32. data/lib/raindrops/aggregate.rb +8 -0
  33. data/lib/raindrops/last_data_recv.rb +102 -0
  34. data/lib/raindrops/linux.rb +77 -0
  35. data/lib/raindrops/middleware/proxy.rb +40 -0
  36. data/lib/raindrops/middleware.rb +153 -0
  37. data/lib/raindrops/struct.rb +62 -0
  38. data/lib/raindrops/watcher.rb +428 -0
  39. data/lib/raindrops.rb +72 -0
  40. data/pkg.mk +151 -0
  41. data/raindrops-maintained.gemspec +1 -0
  42. data/raindrops.gemspec +26 -0
  43. data/setup.rb +1586 -0
  44. data/test/ipv6_enabled.rb +9 -0
  45. data/test/rack_unicorn.rb +11 -0
  46. data/test/test_aggregate_pmq.rb +65 -0
  47. data/test/test_inet_diag_socket.rb +16 -0
  48. data/test/test_last_data_recv.rb +57 -0
  49. data/test/test_last_data_recv_unicorn.rb +69 -0
  50. data/test/test_linux.rb +281 -0
  51. data/test/test_linux_all_tcp_listen_stats.rb +66 -0
  52. data/test/test_linux_all_tcp_listen_stats_leak.rb +43 -0
  53. data/test/test_linux_ipv6.rb +166 -0
  54. data/test/test_linux_middleware.rb +64 -0
  55. data/test/test_linux_reuseport_tcp_listen_stats.rb +51 -0
  56. data/test/test_middleware.rb +128 -0
  57. data/test/test_middleware_unicorn.rb +37 -0
  58. data/test/test_middleware_unicorn_ipv6.rb +37 -0
  59. data/test/test_raindrops.rb +207 -0
  60. data/test/test_raindrops_gc.rb +38 -0
  61. data/test/test_struct.rb +54 -0
  62. data/test/test_tcp_info.rb +88 -0
  63. data/test/test_watcher.rb +186 -0
  64. metadata +193 -0
data/NEWS ADDED
@@ -0,0 +1,384 @@
1
+ === raindrops 0.20.1 / 2023-02-25 00:19 UTC
2
+
3
+ Stats for SO_REUSEPORT sockets are now handled properly.
4
+ Thanks to Dale Hamel for the patches.
5
+
6
+ Dale Hamel (2):
7
+ Fix queue stats for sockets with SO_REUSEPORT
8
+ Fix off by one error in test
9
+
10
+ === raindrops 0.20.0 / 2021-12-06 23:41 UTC
11
+
12
+ Raindrops may now use file-backed mmap() rather than anonymous
13
+ memory. Thanks to KJ Tsanaktsidis for the patch:
14
+
15
+ https://yhbt.net/raindrops-public/20211125065618.3432-1-ktsanaktsidis@zendesk.com/T/
16
+
17
+ The documentation is also updated to note our mail archives are now
18
+ available via IMAP(S).
19
+
20
+ === raindrops 0.19.2 / 2021-05-25 23:13 UTC
21
+
22
+ This release fixes compatibility with GC.compact on Ruby 3.x
23
+ when using ListenStats on Linux. The listener stats
24
+ functionality is rarely used and does not affect most users
25
+ who just have raindrops installed for shared atomic counters.
26
+
27
+ === raindrops 0.19.1 / 2020-01-08 09:31 UTC
28
+
29
+ This release fixes some warnings on newer Rubies.
30
+
31
+ We're no longer on bogomips.org since it's due
32
+ for expiry and I can't pay extortionists for a .org, so
33
+ s/bogomips.org/yhbt.net/ for now, and be prepared to move again
34
+ when extortionists move onto extorting the .net TLD.
35
+
36
+ doc: switch homepage to dark216
37
+ ext/raindrops/extconf: fix cflags reset on ancient CC
38
+ fixes for newer rubies
39
+ replace bogomips.org with yhbt.net
40
+
41
+ === raindrops 0.19.0 - Rack 2.x middleware compatibility / 2017-08-09 23:52 UTC
42
+
43
+ This release fixes Rack 2.x compatibility for the few users of
44
+ Raindrops::Middleware
45
+ <https://bogomips.org/raindrops/Raindrops/Middleware.html>.
46
+ Thanks to Dmytro Shteflyuk for this release.
47
+
48
+ No need to upgrade unless you use Raindrops::Middleware with
49
+ Rack 2.x.
50
+
51
+ There's also a few minor, inconsequential cleanups.
52
+
53
+ Dmytro Shteflyuk (1):
54
+ Properly override respond_to? in Raindrops::Middleware::Proxy
55
+
56
+ Eric Wong (2):
57
+ Ruby thread compatibility updates
58
+ tcp_info: remove unnecessary extconf.h include
59
+
60
+ === raindrops 0.18.0 / 2017-03-23 02:44 UTC
61
+
62
+ The most notable feature of this release is the addition of
63
+ FreeBSD and OpenBSD TCP_INFO support. This includes the
64
+ Raindrops::TCP for portably mapping TCP state names to
65
+ platform-dependent numeric values:
66
+
67
+ https://bogomips.org/raindrops/Raindrops.html#TCP
68
+
69
+ Thanks to Jeremy Evans and Simon Eskildsen on the
70
+ unicorn-public@bogomips.org mailing list for inspiring
71
+ these changes to raindrops.
72
+
73
+ There's also a few internal cleanups, and documentation
74
+ improvements, including some fixes to the largely-forgotten
75
+ Raindrops::Aggreage::PMQ class:
76
+
77
+ https://bogomips.org/raindrops/Raindrops/Aggregate/PMQ.html
78
+
79
+ 20 changes since 0.17.0:
80
+
81
+ test_inet_diag_socket: fix Fixnum deprecation warning
82
+ TODO: add item for IPv6 breakage
83
+ ext: fix documentation for C ext-defined classes
84
+ TCP_Info: custom documentation for #get!
85
+ TypedData C-API conversion
86
+ test_watcher: disable test correctly when aggregate is missing
87
+ tcp_info: support this struct under FreeBSD
88
+ define Raindrops::TCP hash for TCP states
89
+ linux_inet_diag: reduce stack usage and simplify
90
+ avoid reading errno repeatedly
91
+ aggregate/pmq: avoid false sharing of lock buffers
92
+ aggregate/pmq: remove io-extra requirement
93
+ aggregate/pmq: avoid File#stat allocation
94
+ Merge remote-tracking branch 'origin/freebsd'
95
+ Merge remote-tracking branch 'origin/aggregate-pmq'
96
+ doc: remove private email support address
97
+ doc: update location of TCP_INFO-related stuff
98
+ build: avoid olddoc for building the RubyGem
99
+ doc: document Raindrops::TCP hash
100
+ aggregate/pmq: update version numbers for Ruby and Linux
101
+
102
+ === raindrops 0.17.0 - rack 2.x updates / 2016-07-31 15:19 UTC
103
+
104
+ This release features minor updates to support rack 2.x
105
+ while maintaining support for rack 1.2 and later.
106
+ As a result, Ruby 1.8.6 compatibility is gone, but
107
+ Ruby 1.8.7 probably still works, for now.
108
+
109
+ There's also a minor warning fix, doc updates, and
110
+ the homepage now supports HTTPS (HTTP remains supported)
111
+
112
+ 5 changes since raindrops 0.16.0:
113
+ drop Rack::Utils.bytesize dependency
114
+ gemspec: bump Rack dependency
115
+ linux_inet_diag: GCC attribute format check
116
+ use HTTPS and move homepage to https://bogomips.org/raindrops/
117
+ examples: add yahns config, zbatery is abandoned
118
+
119
+ === raindrops 0.16.0 - minor fixes and workarounds / 2016-02-29 12:36 UTC
120
+
121
+ There's mainly a fix/workaround for Ruby 2.3 now returning
122
+ locale-aware strings for File.readlink and our test suite
123
+ using strange paths allowed by *nix.
124
+
125
+ https://bugs.ruby-lang.org/issues/12034
126
+
127
+ tcp_listener_stats won't return "true" object placeholders
128
+ if stats are configured for a non-existent listener.
129
+
130
+ There are also minor optimizations for Ruby 2.2+ (at the expense
131
+ of 2.1 and earlier).
132
+
133
+ And the usual round of minor tweaks and doc updates.
134
+
135
+ 10 changes since v0.15.0:
136
+ gemspec: avoid circular dependency on unicorn
137
+ remove optimizations which made sense for older rubies
138
+ linux: workaround Ruby 2.3 change
139
+ linux: remove Pathname stdlib dependency
140
+ add .gitattributes for Ruby method detection
141
+ middleware: minor bytecode size reduction
142
+ doc: update URLs and references
143
+ README: remove indentation from URLs in RDoc
144
+ linux: tcp_listener_stats drops "true" placeholders
145
+ build: use '--local' domain for dev gem install
146
+
147
+ === raindrops 0.15.0 - non-glibc compat fix on Linux / 2015-07-22 00:30 UTC
148
+
149
+ Thanks to Doug Forster for sending us the report.
150
+ No other fixes
151
+
152
+ * check for the existence of linux/tcp.h
153
+
154
+ === raindrops 0.14.0 - misc doc updates / 2015-06-25 21:50 UTC
155
+
156
+ Eric Wong (7):
157
+ linux_inet_diag: annotate memory freeing on diag errors
158
+ README: trim intro and update license
159
+ modernize packaging and documentation
160
+ move mailing list to raindrops-public@bogomips.org
161
+ linux_inet_diag: clarify *fprintf usage without GVL
162
+ TODO: add item for unix_diag and udp_diag
163
+ linux_inet_diag: fix Wshorten-64-to-32 warnings
164
+
165
+ Hleb Valoshka (1):
166
+ Add setup and teardown for ipv6 tests
167
+
168
+ === raindrops 0.13.0 several minor fixes and improvements / 2014-02-18 20:59 UTC
169
+
170
+ Most notably, this release is necessary for Ruby 2.2 (dev).
171
+ Thanks to Koichi Sasada for the bug report!
172
+
173
+ Eric Wong (5):
174
+ Rakefile: remove raa_update task
175
+ last_data_recv: do not assume Unicorn includes all constants
176
+ raindrops.gemspec: add wrongdoc dev dependency
177
+ linux_inet_diag: fix Ruby 2.2 (dev) build
178
+ license: use LGPLv2.1 or later (was LGPL (2.1|3.0)-only)
179
+
180
+ Hleb Valoshka (1):
181
+ Remove Scope IDs from IPv6 addresses.
182
+
183
+ === raindrops 0.12.0 - compatibility fixes / 2013-09-02 10:33 UTC
184
+
185
+ This release fixes builds on systems where compilers target i386
186
+ (and not later x86 systems). There are also minor improvements for
187
+ Ruby 2.1.0dev and Rubinius.
188
+
189
+ Eric Wong (5):
190
+ doc: add email address to generated doc/site
191
+ README: update regarding Ruby support status
192
+ extconf: try harder for gcc atomics in i386-configured systems
193
+ linux_inet_diag: improve compatibility with newer GCs
194
+ test_watcher: fix for Ruby trunk r40195 and later
195
+
196
+ === raindrops 0.11.0 - minor fixes improvements / 2013-04-20 23:10 UTC
197
+
198
+ Eric Wong (7):
199
+ raindrops: favor configured processor count over online count
200
+ watcher: set Content-Type via assignment
201
+ Linux::TCP_Info: implement #get! instance method
202
+ linux_inet_diag: avoid unnecessary sockaddr initialization
203
+ .gitignore: add .rbx
204
+ switch back to gemspec development dependencies
205
+ linux_inet_diag: better align listener_stats struct
206
+
207
+ Lawrence Pit (1):
208
+ Watcher: Use relative paths in HTML links
209
+
210
+ === raindrops 0.10.0 - minor feature updates / 2012-06-19 08:30 UTC
211
+
212
+ Improvements to the Unix domain socket handling and small
213
+ bugfixes throughout.
214
+
215
+ Support for the "unix_diag" facility in Linux 3.3+ is planned
216
+ but not yet implemented (patches to raindrops@librelist.org
217
+ appreciated)
218
+
219
+ Brian Corrigan (1):
220
+ resolve symlinks to Unix domain sockets
221
+
222
+ Eric Wong (6):
223
+ unix_listener_stats follows and remembers symlinks
224
+ middleware/proxy: favor __send__ for method dispatch
225
+ unix: show zero-value stats for idle listeners
226
+ test_watcher: fix incorrect request/date comparison
227
+ watcher: sort index of listener listing
228
+ watcher: do not require Rack::Head for HEAD response
229
+
230
+ See "git log v0.9.0..v0.10.0" for full details
231
+
232
+ === raindrops 0.9.0 - minor middleware/proxy update / 2012-05-21 00:06 UTC
233
+
234
+ Raindrops::Middleware::Proxy now forwards method_missing
235
+ to the proxied body object. This allows compatibility
236
+ with non-standard Rack extensions employed by some
237
+ middlewares, applications, or servers.
238
+
239
+ Thanks to Ben Somers for the feature!
240
+
241
+ === raindrops 0.8.1 - compatibility fixes / 2012-05-12 05:58 UTC
242
+
243
+ This release fixes a build problem found under a current SmartOS. This
244
+ release also runs successfully on FreeBSD 9.0 under both x86-64 and
245
+ i386.
246
+
247
+ There are also documentation updates from Aman Gupta and a test suite
248
+ fix from Jeremy Evans for OpenBSD.
249
+
250
+ raindrops fully supports unicorn on recent versions of FreeBSD, OpenBSD,
251
+ SmartOS, and possibly other Free Software systems. Portability reports
252
+ and fixes for Free Software systems is greatly appreciated at
253
+ raindrops@librelist.org
254
+
255
+ Non-Free systems will never be supported.
256
+
257
+ raindrops requires the Linux 2.6.18 or later for full functionality
258
+ (which unicorn does not require). Future releases will take advantage
259
+ of the unix_diag functionality found in the Linux 3.3 (and later)
260
+ kernels.
261
+
262
+ === raindrops 0.8.0 - watcher updates / 2011-10-14 22:00 UTC
263
+
264
+ There are various updates to the Raindrops::Watcher Rack app.
265
+ Most notably, the timestamp where the a statistic first and last
266
+ hit its peak value (active/queued connections) is captured.
267
+
268
+ As usual, the latest Raindrops::Watcher is running at:
269
+ http://raindrops-demo.bogomips.org/
270
+
271
+ === raindrops 0.7.0 - FreeBSD fix, code cleanups / 2011-06-27 07:26 UTC
272
+
273
+ This release fixes a build issue on FreeBSD. There are various
274
+ documentation and code cleanups, too.
275
+
276
+ === raindrops 0.6.1 - fix build on non-Linux / 2011-03-21 22:31 UTC
277
+
278
+ TCP_INFO support couldn't compile under non-Linux, this was
279
+ broken since 0.5.0 when TCP_INFO support was introduced.
280
+
281
+ Thanks to Ben Bleything for the report.
282
+
283
+ === raindrops 0.6.0 - polishing up the last release / 2011-03-21 21:46 UTC
284
+
285
+ Following up the huge 0.5.0 release, 0.6.0 makes
286
+ some minor improvements:
287
+
288
+ * minor UI/UX improvements for Watcher Rack app
289
+ * set close-on-exec by default for inet_diag sockets
290
+ * inet_diag build fixes for newer GNU libc6
291
+ * --with-atomic_ops-dir= build option added
292
+
293
+ === raindrops 0.5.0 - more Linux extras! / 2011-03-17 03:13 UTC
294
+
295
+ Portable changes:
296
+ * Raindrops are now resizable within the limits of system page size
297
+ * Raindrops::Middleware proxies +to_path+ in response bodies
298
+ * More documentation
299
+
300
+ Linux-only changes:
301
+ * Raindrops::LastDataRecv[1] Rack application
302
+ * Raindrops::Watcher[2] Rack application
303
+ * Raindrops::TCP_Info[3] class for capturing TCP connection stats
304
+ * IPv6 support for inet_diag
305
+ * faster inet_diag stats for multiple sockets
306
+
307
+ There is also a demo server running the Watcher and Middleware
308
+ components. It's capped to 30 concurrent users, so go easy on
309
+ it:
310
+
311
+ Raindrops::Watcher: http://raindrops-demo.bogomips.org/
312
+ Raindrops::Middleware: http://raindrops-demo.bogomips.org/_raindrops
313
+
314
+ [1] http://raindrops.bogomips.org/Raindrops/LastDataRecv.html
315
+ [2] http://raindrops.bogomips.org/Raindrops/Watcher.html
316
+ [3] http://raindrops.bogomips.org/Raindrops/TCP_Info.html
317
+
318
+ === raindrops 0.4.1 - more portability! / 2010-09-26 06:49 UTC
319
+
320
+ Rubinius 1.1.0 support is complete. Atomic operations
321
+ are now available under FreeBSD 7.0 now.
322
+
323
+ Full changelog below:
324
+
325
+ commit 8a2a725a4ad074af493e5aa075155eda8b1d6be7
326
+ Author: Eric Wong <e+absinthe@yhbt.net>
327
+ Date: Sat Sep 25 00:14:48 2010 -0700
328
+
329
+ force -march=i486 where GCC is targeted for i386
330
+
331
+ Nobody uses i386 anymore (especially not with Ruby!),
332
+ but some systems like FreeBSD 7.0 still target GCC at
333
+ i386 by default, so we force GCC to use a slightly
334
+ more modern instruction set and allow it to use
335
+ atomic builtins.
336
+
337
+ commit 256cc7c8ffb441dcf2d2a2da3bbbcc82546962d9
338
+ Author: Eric Wong <e+absinthe@yhbt.net>
339
+ Date: Sat Sep 25 00:01:46 2010 -0700
340
+
341
+ disable Linux-only code on non-Linux
342
+
343
+ This allows us to build and link correctly on FreeBSD 7.0
344
+
345
+ commit 22a5a39d75faa890048d07ae4ea0d494acd414ce
346
+ Author: Eric Wong <e@yhbt.net>
347
+ Date: Sat Sep 25 06:25:42 2010 +0000
348
+
349
+ linux: workaround missing RSTRUCT* macros in rbx
350
+
351
+ Rubinius does not include macros for accessing
352
+ Struct members in the C API.
353
+
354
+ ref: http://github.com/evanphx/rubinius/issues/494
355
+
356
+ === raindrops 0.4.0 - flowing into new systems! / 2010-09-21 22:32 UTC
357
+
358
+ Non-GCC 4.x users may use the libatomic_ops[1] package to
359
+ compile Raindrops. Memory efficiency is improved for modern
360
+ glibc users with run-time cache line size detection, we no
361
+ longer assume 128 byte cache lines.
362
+
363
+ [1] - http://www.hpl.hp.com/research/linux/atomic_ops/
364
+
365
+ === raindrops v0.3.0 - LGPL v2.1 and v3.0 / 2010-07-10 22:29 UTC
366
+
367
+ Raindrops is now licensed under the LGPLv2.1 or LGPLv3 (from
368
+ LGPLv3-only) to allow bundling in GPLv2-only applications.
369
+
370
+ There are small documentation updates and updated examples
371
+ at http://raindrops.bogomips.org/examples/
372
+
373
+ === raindrops 0.2.0 - raining penguins! / 2010-05-05 00:35 UTC
374
+
375
+ For servers running Unicorn 0.98.0 (and derivative servers)
376
+ under Linux, :listeners no longer needs to be passed explicitly
377
+ when configuring the Rack middleware.
378
+
379
+ Some small documentation updates and cleanups, too.
380
+
381
+ === raindrops 0.1.0 / 2010-04-08 00:45 UTC
382
+
383
+ initial release
384
+
data/README ADDED
@@ -0,0 +1,101 @@
1
+ = raindrops - real-time stats for preforking Rack servers
2
+
3
+ raindrops is a real-time stats toolkit to show statistics for Rack HTTP
4
+ servers. It is designed for preforking servers such as unicorn, but
5
+ should support any Rack HTTP server on platforms supporting POSIX shared
6
+ memory. It may also be used as a generic scoreboard for sharing atomic
7
+ counters across multiple processes.
8
+
9
+ == Features
10
+
11
+ * counters are shared across all forked children and lock-free
12
+
13
+ * counters are kept on separate cache lines to reduce contention under SMP
14
+
15
+ * may expose server statistics as a Rack Middleware endpoint
16
+ (default: "/_raindrops")
17
+
18
+ * middleware displays the number of actively processing and writing
19
+ clients from a single request regardless of which worker process
20
+ it hits.
21
+
22
+ == Linux-only Extra Features!
23
+
24
+ * Middleware response includes extra stats for bound TCP and
25
+ Unix domain sockets (configurable, it can include stats from
26
+ other TCP or UNIX domain socket servers).
27
+
28
+ * TCP socket stats use efficient inet_diag facilities via netlink
29
+ instead of parsing /proc/net/tcp to minimize overhead.
30
+ This was fun to discover and write.
31
+
32
+ * TCP_Info reporting may be used to check stat for every accepted client
33
+ on TCP servers
34
+
35
+ Users of older Linux kernels need to ensure that the the "inet_diag"
36
+ and "tcp_diag" kernel modules are loaded as they do not autoload correctly
37
+
38
+ == Install
39
+
40
+ We recommend GCC 4+ (or compatible) to support the __sync builtins
41
+ (__sync_{add,sub}_and_fetch()):
42
+
43
+ https://gcc.gnu.org/onlinedocs/gcc/_005f_005fsync-Builtins.html
44
+
45
+ For non-GCC 4+ users, we also support compilation with the libatomic_ops
46
+ package starting with Raindrops 0.4.0:
47
+
48
+ https://github.com/ivmai/libatomic_ops
49
+
50
+ If you're using a packaged Ruby distribution, make sure you have a C
51
+ compiler and the matching Ruby development libraries and headers.
52
+
53
+ If you use RubyGems:
54
+
55
+ gem install raindrops
56
+
57
+ == Usage
58
+
59
+ See Raindrops::Middleware and Raindrops::LastDataRecv documentation for
60
+ use Rack servers. The entire library is fully-documented and we are
61
+ responsive on the publicly archived mailbox
62
+ (mailto:raindrops-public@yhbt.net) if you have any questions or comments.
63
+
64
+ == Development
65
+
66
+ You can get the latest source via git from the following locations:
67
+
68
+ https://yhbt.net/raindrops.git
69
+ http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops.git
70
+ http://repo.or.cz/w/raindrops.git (gitweb mirror)
71
+
72
+ Snapshots and tarballs are available.
73
+
74
+ Inline patches (from "git format-patch") to the mailbox are
75
+ preferred because they allow code review and comments in the reply to
76
+ the patch.
77
+
78
+ We will adhere to mostly the same conventions for patch submissions as
79
+ git itself. See the Documentation/SubmittingPatches document
80
+ distributed with git on on patch submission guidelines to follow. Just
81
+ don't email the git mailing list or maintainer with raindrops patches.
82
+
83
+ raindrops is licensed under the LGPL-2.1+
84
+
85
+ == Contact
86
+
87
+ All feedback (bug reports, user/development discussion, patches, pull
88
+ requests) go to the publicly archived mailbox:
89
+ mailto:raindrops-public@yhbt.net
90
+
91
+ Mail archives are available over HTTP(S), IMAP(S) and NNTP(S):
92
+
93
+ * https://yhbt.net/raindrops-public/
94
+ * http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops-public/
95
+ * imaps://yhbt.net/inbox.comp.lang.ruby.raindrops.0
96
+ * imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops.0
97
+ * nntps://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
98
+ * nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops
99
+
100
+ Since archives are public, scrub sensitive information and
101
+ use anonymity tools such as Tor or Mixmaster if you deem necessary.
data/TODO ADDED
@@ -0,0 +1,3 @@
1
+ * fix IPv6 inet_diag reporting for Raindrops::Middleware
2
+ * pure Ruby version for non-forking servers (patches welcome!)
3
+ * unix_diag and udp_diag support
@@ -0,0 +1,3 @@
1
+ /data
2
+ /news
3
+ /requests
@@ -0,0 +1,4 @@
1
+ # group_name max expire headers_only
2
+ gmane.comp.lang.ruby.raindrops.general 1000000000 1000000000 0
3
+
4
+ # usage: slrnpull -d $PWD -h news.gmane.org --no-post
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/ruby
2
+ # -*- encoding: binary -*-
3
+ $stdout.sync = $stderr.sync = true
4
+ # this is used to show or watch the number of active and queued
5
+ # connections on any listener socket from the command line
6
+
7
+ require 'raindrops'
8
+ require 'optparse'
9
+ require 'ipaddr'
10
+ require 'time'
11
+ begin
12
+ require 'sleepy_penguin'
13
+ rescue LoadError
14
+ end
15
+ usage = "Usage: #$0 [-d DELAY] [-t QUEUED_THRESHOLD] ADDR..."
16
+ ARGV.size > 0 or abort usage
17
+ delay = false
18
+ queued_thresh = -1
19
+ # "normal" exits when driven on the command-line
20
+ trap(:INT) { exit 130 }
21
+ trap(:PIPE) { exit 0 }
22
+
23
+ OptionParser.new('', 24, ' ') do |opts|
24
+ opts.banner = usage
25
+ opts.on('-d', '--delay=DELAY', Float) { |n| delay = n }
26
+ opts.on('-t', '--queued-threshold=INT', Integer) { |n| queued_thresh = n }
27
+ opts.on('-a', '--all') { } # noop
28
+ opts.parse! ARGV
29
+ end
30
+
31
+ begin
32
+ require 'aggregate'
33
+ rescue LoadError
34
+ $stderr.puts "Aggregate missing, USR1 and USR2 handlers unavailable"
35
+ end if delay
36
+
37
+ if delay && defined?(SleepyPenguin::TimerFD)
38
+ @tfd = SleepyPenguin::TimerFD.new
39
+ @tfd.settime nil, delay, delay
40
+ def delay_for(seconds)
41
+ @tfd.expirations
42
+ end
43
+ else
44
+ alias delay_for sleep
45
+ end
46
+
47
+ agg_active = agg_queued = nil
48
+ if delay && defined?(Aggregate)
49
+ agg_active = Aggregate.new
50
+ agg_queued = Aggregate.new
51
+
52
+ def dump_aggregate(label, agg)
53
+ $stderr.write "--- #{label} ---\n"
54
+ %w(count min max outliers_low outliers_high mean std_dev).each do |f|
55
+ $stderr.write "#{f}=#{agg.__send__ f}\n"
56
+ end
57
+ $stderr.write "#{agg}\n\n"
58
+ end
59
+
60
+ trap(:USR1) do
61
+ dump_aggregate "active", agg_active
62
+ dump_aggregate "queued", agg_queued
63
+ end
64
+ trap(:USR2) do
65
+ agg_active = Aggregate.new
66
+ agg_queued = Aggregate.new
67
+ end
68
+ $stderr.puts "USR1(dump_aggregate) and USR2(reset) handlers ready for PID=#$$"
69
+ end
70
+
71
+ ARGV.each do |addr|
72
+ addr =~ %r{\A(127\..+):(\d+)\z} or next
73
+ host, port = $1, $2
74
+ hex_port = '%X' % port.to_i
75
+ ip_addr = IPAddr.new(host)
76
+ hex_host = ip_addr.hton.each_byte.inject('') { |s,o| s << '%02X' % o }
77
+ socks = File.readlines('/proc/net/tcp')
78
+ hex_addr = "#{hex_host}:#{hex_port}"
79
+ if socks.grep(/^\s+\d+:\s+#{hex_addr}\s+/).empty? &&
80
+ ! socks.grep(/^\s+\d+:\s+00000000:#{hex_port}\s+/).empty?
81
+ warn "W: #{host}:#{port} (#{hex_addr}) not found in /proc/net/tcp"
82
+ warn "W: Did you mean 0.0.0.0:#{port}?"
83
+ end
84
+ end
85
+
86
+ len = "address".size
87
+ now = nil
88
+ tcp, unix = [], []
89
+ ARGV.each do |addr|
90
+ bs = addr.respond_to?(:bytesize) ? addr.bytesize : addr.size
91
+ len = bs if bs > len
92
+ (addr =~ %r{\A/} ? unix : tcp) << addr
93
+ end
94
+ combined = {}
95
+ tcp_args = unix_args = nil
96
+ unless tcp.empty? && unix.empty?
97
+ tcp_args = tcp
98
+ unix_args = unix
99
+ end
100
+ sock = Raindrops::InetDiagSocket.new if tcp
101
+
102
+ len = 35 if len > 35
103
+ fmt = "%20s % #{len}s % 10u % 10u\n"
104
+ $stderr.printf fmt.tr('u','s'), *%w(timestamp address active queued)
105
+
106
+ begin
107
+ if now
108
+ combined.clear
109
+ now = nil
110
+ end
111
+ combined.merge! Raindrops::Linux.tcp_listener_stats(tcp_args, sock)
112
+ combined.merge! Raindrops::Linux.unix_listener_stats(unix_args)
113
+ combined.each do |addr,stats|
114
+ active, queued = stats.active, stats.queued
115
+ if agg_active
116
+ agg_active << active
117
+ agg_queued << queued
118
+ end
119
+ next if queued < queued_thresh
120
+ printf fmt, now ||= Time.now.utc.iso8601, addr, active, queued
121
+ end
122
+ end while delay && delay_for(delay)
@@ -0,0 +1,5 @@
1
+ # sample stand-alone rackup application for Raindrops::Middleware
2
+ require 'rack/lobster'
3
+ require 'raindrops'
4
+ use Raindrops::Middleware
5
+ run Rack::Lobster.new
@@ -0,0 +1,4 @@
1
+ # Sample standalone Rack application, recommended use is with Zbatery
2
+ # See zbatery.conf.rb
3
+ require "raindrops"
4
+ run Raindrops::Watcher.new
@@ -0,0 +1,13 @@
1
+ # This is a snippet of the config that powers
2
+ # https://yhbt.net/raindrops-demo/
3
+ # This may be used with the packaged zbatery.conf.rb
4
+ #
5
+ # zbatery -c zbatery.conf.ru watcher_demo.ru -E none
6
+ require "raindrops"
7
+ use Raindrops::Middleware
8
+ listeners = %w(
9
+ 0.0.0.0:9418
10
+ 0.0.0.0:80
11
+ /tmp/.r
12
+ )
13
+ run Raindrops::Watcher.new :listeners => listeners
@@ -0,0 +1,30 @@
1
+ # Inlined rack app using yahns server (git clone git://yhbt.net/yahns.git)
2
+ # Usage: yahns -c /path/to/this/file.conf.rb
3
+ # There is no separate config.ru file for this example,
4
+ # but rack_app may also be a string pointing to the path of a
5
+ # config.ru file
6
+
7
+ require 'rack'
8
+ rack_app = Rack::Builder.new do
9
+ use Rack::Head
10
+ addr = %w(0.0.0.0:9418 0.0.0.0:443 [::]:443 0.0.0.0:80 [::]:80
11
+ 127.0.0.1:6081 127.0.0.1:280 0.0.0.0:119 [::]:119)
12
+ use Raindrops::Middleware, listeners: addr
13
+ run Raindrops::Watcher.new(listeners: addr)
14
+ end.to_app
15
+ # rack_app = '/path/to/config.ru' # a more standard config
16
+
17
+ app(:rack, rack_app) do
18
+ # I keep IPv4 and IPv6 on separate sockets to avoid ugly
19
+ # IPv4-mapped-IPv6 addresses:
20
+ listen 8080
21
+ listen '[::]:8080', ipv6only: true
22
+ client_max_body_size 0 # no POST or any uploads
23
+ client_timeout 5
24
+ output_buffering false # needed for /tail/ endpoint to avoid ENOSPC
25
+ queue { worker_threads 30 }
26
+ end
27
+
28
+ # logging is optional, but recommended for diagnosing problems
29
+ # stderr_path '/var/log/yahns/stderr-raindrops.log'
30
+ # stdout_path '/var/log/yahns/stdout-raindrops.log'