precompiled-raindrops 0.18.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.
- checksums.yaml +7 -0
- data/.document +7 -0
- data/.gitattributes +4 -0
- data/.github/workflows/cibuildgem.yaml +90 -0
- data/.gitignore +16 -0
- data/.olddoc.yml +16 -0
- data/COPYING +165 -0
- data/GIT-VERSION-GEN +40 -0
- data/GNUmakefile +4 -0
- data/Gemfile +1 -0
- data/LICENSE +16 -0
- data/README +111 -0
- data/Rakefile +0 -0
- data/TODO +3 -0
- data/archive/.gitignore +3 -0
- data/archive/slrnpull.conf +4 -0
- data/examples/linux-listener-stats.rb +123 -0
- data/examples/middleware.ru +6 -0
- data/examples/watcher.ru +5 -0
- data/examples/watcher_demo.ru +14 -0
- data/examples/yahns.conf.rb +31 -0
- data/examples/zbatery.conf.rb +17 -0
- data/ext/raindrops/extconf.rb +164 -0
- data/ext/raindrops/khashl.h +444 -0
- data/ext/raindrops/linux_inet_diag.c +719 -0
- data/ext/raindrops/my_fileno.h +16 -0
- data/ext/raindrops/raindrops.c +487 -0
- data/ext/raindrops/raindrops_atomic.h +23 -0
- data/ext/raindrops/tcp_info.c +245 -0
- data/lib/raindrops/aggregate/last_data_recv.rb +95 -0
- data/lib/raindrops/aggregate/pmq.rb +246 -0
- data/lib/raindrops/aggregate.rb +9 -0
- data/lib/raindrops/last_data_recv.rb +103 -0
- data/lib/raindrops/linux.rb +78 -0
- data/lib/raindrops/middleware/proxy.rb +41 -0
- data/lib/raindrops/middleware.rb +154 -0
- data/lib/raindrops/struct.rb +63 -0
- data/lib/raindrops/watcher.rb +429 -0
- data/lib/raindrops.rb +79 -0
- data/pkg.mk +151 -0
- data/raindrops.gemspec +26 -0
- data/setup.rb +1587 -0
- data/test/ipv6_enabled.rb +10 -0
- data/test/rack_unicorn.rb +12 -0
- data/test/test_aggregate_pmq.rb +66 -0
- data/test/test_inet_diag_socket.rb +17 -0
- data/test/test_last_data_recv.rb +58 -0
- data/test/test_last_data_recv_unicorn.rb +70 -0
- data/test/test_linux.rb +282 -0
- data/test/test_linux_all_tcp_listen_stats.rb +67 -0
- data/test/test_linux_all_tcp_listen_stats_leak.rb +44 -0
- data/test/test_linux_ipv6.rb +167 -0
- data/test/test_linux_middleware.rb +65 -0
- data/test/test_linux_reuseport_tcp_listen_stats.rb +52 -0
- data/test/test_middleware.rb +129 -0
- data/test/test_middleware_unicorn.rb +38 -0
- data/test/test_middleware_unicorn_ipv6.rb +38 -0
- data/test/test_raindrops.rb +208 -0
- data/test/test_raindrops_gc.rb +39 -0
- data/test/test_struct.rb +55 -0
- data/test/test_tcp_info.rb +89 -0
- data/test/test_watcher.rb +187 -0
- metadata +194 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 1a7860d88cd2e01099b9e16d9cc563cfb905987bccb8f2180620d0be16f9b73f
|
|
4
|
+
data.tar.gz: 106190695d643849de0e74593c2d18f24534cc1f2061ca2f3351c1cbaafdad35
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 19304778f8fa2c8896755e34300f44a976404a347636d1e4a55be28f7ed78814da3e595025aac22702c57f5afab89910e23d1d5f0a8719ab283105eef2512d6b
|
|
7
|
+
data.tar.gz: 118a404365b03160eddc87d65421759e29c2f5726047ae739d60df1ab6a4ffd4174c70ff3f20b830604a5aea7b8986eff8a09e2ce9f4860b5bd2d8b8a8c54612
|
data/.document
ADDED
data/.gitattributes
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
name: "Package and release gems with precompiled binaries"
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
inputs:
|
|
5
|
+
release:
|
|
6
|
+
description: "If the whole build passes on all platforms, release the gems on RubyGems.org"
|
|
7
|
+
required: false
|
|
8
|
+
type: boolean
|
|
9
|
+
default: false
|
|
10
|
+
jobs:
|
|
11
|
+
compile:
|
|
12
|
+
timeout-minutes: 20
|
|
13
|
+
name: "Cross compile the gem on different ruby versions"
|
|
14
|
+
env:
|
|
15
|
+
RUBY_CC_VERSION: "3.4.6:3.3.8"
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
os: ["macos-latest", "ubuntu-22.04"]
|
|
19
|
+
runs-on: "${{ matrix.os }}"
|
|
20
|
+
steps:
|
|
21
|
+
- name: "Checkout code"
|
|
22
|
+
uses: "actions/checkout@v5"
|
|
23
|
+
- name: "Setup Ruby"
|
|
24
|
+
uses: "ruby/setup-ruby@v1"
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: "3.1.7"
|
|
27
|
+
bundler-cache: true
|
|
28
|
+
- name: "Run cibuildgem"
|
|
29
|
+
uses: "shopify/cibuildgem/.github/actions/cibuildgem@main"
|
|
30
|
+
with:
|
|
31
|
+
step: "compile"
|
|
32
|
+
test:
|
|
33
|
+
timeout-minutes: 20
|
|
34
|
+
name: "Run the test suite"
|
|
35
|
+
needs: compile
|
|
36
|
+
strategy:
|
|
37
|
+
matrix:
|
|
38
|
+
os: ["macos-latest", "ubuntu-22.04"]
|
|
39
|
+
rubies: ["3.4"]
|
|
40
|
+
type: ["cross"]
|
|
41
|
+
runs-on: "${{ matrix.os }}"
|
|
42
|
+
steps:
|
|
43
|
+
- name: "Checkout code"
|
|
44
|
+
uses: "actions/checkout@v5"
|
|
45
|
+
- name: "Setup Ruby"
|
|
46
|
+
uses: "ruby/setup-ruby@v1"
|
|
47
|
+
with:
|
|
48
|
+
ruby-version: "${{ matrix.rubies }}"
|
|
49
|
+
bundler-cache: true
|
|
50
|
+
- name: "Run cibuildgem"
|
|
51
|
+
uses: "shopify/cibuildgem/.github/actions/cibuildgem@main"
|
|
52
|
+
with:
|
|
53
|
+
step: "test_${{ matrix.type }}"
|
|
54
|
+
test-command: "make test-unit"
|
|
55
|
+
install:
|
|
56
|
+
timeout-minutes: 5
|
|
57
|
+
name: "Verify the gem can be installed"
|
|
58
|
+
needs: test
|
|
59
|
+
strategy:
|
|
60
|
+
matrix:
|
|
61
|
+
os: ["macos-latest", "ubuntu-22.04"]
|
|
62
|
+
runs-on: "${{ matrix.os }}"
|
|
63
|
+
steps:
|
|
64
|
+
- name: "Setup Ruby"
|
|
65
|
+
uses: "ruby/setup-ruby@v1"
|
|
66
|
+
with:
|
|
67
|
+
ruby-version: "3.4"
|
|
68
|
+
- name: "Run cibuildgem"
|
|
69
|
+
uses: "shopify/cibuildgem/.github/actions/cibuildgem@main"
|
|
70
|
+
with:
|
|
71
|
+
step: "install"
|
|
72
|
+
release:
|
|
73
|
+
environment: release
|
|
74
|
+
permissions:
|
|
75
|
+
id-token: write
|
|
76
|
+
contents: read
|
|
77
|
+
timeout-minutes: 5
|
|
78
|
+
if: ${{ inputs.release }}
|
|
79
|
+
name: "Release all gems with RubyGems"
|
|
80
|
+
needs: install
|
|
81
|
+
runs-on: "ubuntu-latest"
|
|
82
|
+
steps:
|
|
83
|
+
- name: "Setup Ruby"
|
|
84
|
+
uses: "ruby/setup-ruby@v1"
|
|
85
|
+
with:
|
|
86
|
+
ruby-version: "4.0.0"
|
|
87
|
+
- name: "Run cibuildgem"
|
|
88
|
+
uses: "shopify/cibuildgem/.github/actions/cibuildgem@main"
|
|
89
|
+
with:
|
|
90
|
+
step: "release"
|
data/.gitignore
ADDED
data/.olddoc.yml
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
---
|
|
2
|
+
cgit_url: https://yhbt.net/raindrops.git/
|
|
3
|
+
rdoc_url: https://yhbt.net/raindrops/
|
|
4
|
+
public_email: raindrops-public@yhbt.net
|
|
5
|
+
ml_url:
|
|
6
|
+
- https://yhbt.net/raindrops-public/
|
|
7
|
+
- http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops-public
|
|
8
|
+
imap_url:
|
|
9
|
+
- imaps://yhbt.net/inbox.comp.lang.ruby.raindrops.0
|
|
10
|
+
- imap://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops.0
|
|
11
|
+
nntp_url:
|
|
12
|
+
- nntps://news.public-inbox.org/inbox.comp.lang.ruby.raindrops
|
|
13
|
+
- nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.lang.ruby.raindrops
|
|
14
|
+
source_code:
|
|
15
|
+
- git clone https://yhbt.net/raindrops.git
|
|
16
|
+
- torsocks git clone http://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/raindrops.git
|
data/COPYING
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
data/GIT-VERSION-GEN
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
|
|
3
|
+
GVF=GIT-VERSION-FILE
|
|
4
|
+
DEF_VER=v0.20.1
|
|
5
|
+
|
|
6
|
+
LF='
|
|
7
|
+
'
|
|
8
|
+
|
|
9
|
+
# First see if there is a version file (included in release tarballs),
|
|
10
|
+
# then try git-describe, then default.
|
|
11
|
+
if test -f version
|
|
12
|
+
then
|
|
13
|
+
VN=$(cat version) || VN="$DEF_VER"
|
|
14
|
+
elif test -d .git -o -f .git &&
|
|
15
|
+
VN=$(git describe --abbrev=4 HEAD 2>/dev/null) &&
|
|
16
|
+
case "$VN" in
|
|
17
|
+
*$LF*) (exit 1) ;;
|
|
18
|
+
v[0-9]*)
|
|
19
|
+
git update-index -q --refresh
|
|
20
|
+
test -z "$(git diff-index --name-only HEAD --)" ||
|
|
21
|
+
VN="$VN-dirty" ;;
|
|
22
|
+
esac
|
|
23
|
+
then
|
|
24
|
+
VN=$(echo "$VN" | sed -e 's/-/./g');
|
|
25
|
+
else
|
|
26
|
+
VN="$DEF_VER"
|
|
27
|
+
fi
|
|
28
|
+
|
|
29
|
+
VN=$(expr "$VN" : v*'\(.*\)')
|
|
30
|
+
|
|
31
|
+
if test -r $GVF
|
|
32
|
+
then
|
|
33
|
+
VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
|
|
34
|
+
else
|
|
35
|
+
VC=unset
|
|
36
|
+
fi
|
|
37
|
+
test "$VN" = "$VC" || {
|
|
38
|
+
echo >&2 "GIT_VERSION = $VN"
|
|
39
|
+
echo "GIT_VERSION = $VN" >$GVF
|
|
40
|
+
}
|
data/GNUmakefile
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
source "https://rubygems.org"
|
data/LICENSE
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
raindrops is copyrighted Free Software by all contributors, see 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 the terms of the GNU
|
|
5
|
+
Lesser General Public License (LGPL) as published by the Free Software
|
|
6
|
+
Foundation, version {2.1}[https://www.gnu.org/licenses/lgpl-2.1.txt] or
|
|
7
|
+
later. Currently version {3}[https://www.gnu.org/licenses/lgpl-3.0.txt],
|
|
8
|
+
is preferred (see link:COPYING).
|
|
9
|
+
|
|
10
|
+
raindrops is distributed in the hope that it will be useful, but WITHOUT
|
|
11
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
|
13
|
+
License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Lesser General Public License
|
|
16
|
+
along with the raindrops; if not, see <https://www.gnu.org/licenses/>
|
data/README
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
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.
|
|
102
|
+
|
|
103
|
+
There is NO WARRANTY whatsoever if anything goes wrong and
|
|
104
|
+
no commercial support will ever be provided by the amateur maintainer.
|
|
105
|
+
raindrops hackers are NOT responsible for your supply chain security:
|
|
106
|
+
read and understand it yourself or get someone you trust to audit it.
|
|
107
|
+
Malicious commits and releases will be made if under duress. The only
|
|
108
|
+
defense you'll ever have is from reviewing the source code.
|
|
109
|
+
|
|
110
|
+
No user or contributor will ever be expected to sacrifice their own
|
|
111
|
+
security by running JavaScript or revealing any personal information.
|
data/Rakefile
ADDED
|
File without changes
|
data/TODO
ADDED
data/archive/.gitignore
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
# -*- encoding: binary -*-
|
|
3
|
+
# frozen_string_literal: false
|
|
4
|
+
$stdout.sync = $stderr.sync = true
|
|
5
|
+
# this is used to show or watch the number of active and queued
|
|
6
|
+
# connections on any listener socket from the command line
|
|
7
|
+
|
|
8
|
+
require 'raindrops'
|
|
9
|
+
require 'optparse'
|
|
10
|
+
require 'ipaddr'
|
|
11
|
+
require 'time'
|
|
12
|
+
begin
|
|
13
|
+
require 'sleepy_penguin'
|
|
14
|
+
rescue LoadError
|
|
15
|
+
end
|
|
16
|
+
usage = "Usage: #$0 [-d DELAY] [-t QUEUED_THRESHOLD] ADDR..."
|
|
17
|
+
ARGV.size > 0 or abort usage
|
|
18
|
+
delay = false
|
|
19
|
+
queued_thresh = -1
|
|
20
|
+
# "normal" exits when driven on the command-line
|
|
21
|
+
trap(:INT) { exit 130 }
|
|
22
|
+
trap(:PIPE) { exit 0 }
|
|
23
|
+
|
|
24
|
+
OptionParser.new('', 24, ' ') do |opts|
|
|
25
|
+
opts.banner = usage
|
|
26
|
+
opts.on('-d', '--delay=DELAY', Float) { |n| delay = n }
|
|
27
|
+
opts.on('-t', '--queued-threshold=INT', Integer) { |n| queued_thresh = n }
|
|
28
|
+
opts.on('-a', '--all') { } # noop
|
|
29
|
+
opts.parse! ARGV
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
begin
|
|
33
|
+
require 'aggregate'
|
|
34
|
+
rescue LoadError
|
|
35
|
+
$stderr.puts "Aggregate missing, USR1 and USR2 handlers unavailable"
|
|
36
|
+
end if delay
|
|
37
|
+
|
|
38
|
+
if delay && defined?(SleepyPenguin::TimerFD)
|
|
39
|
+
@tfd = SleepyPenguin::TimerFD.new
|
|
40
|
+
@tfd.settime nil, delay, delay
|
|
41
|
+
def delay_for(seconds)
|
|
42
|
+
@tfd.expirations
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
alias delay_for sleep
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
agg_active = agg_queued = nil
|
|
49
|
+
if delay && defined?(Aggregate)
|
|
50
|
+
agg_active = Aggregate.new
|
|
51
|
+
agg_queued = Aggregate.new
|
|
52
|
+
|
|
53
|
+
def dump_aggregate(label, agg)
|
|
54
|
+
$stderr.write "--- #{label} ---\n"
|
|
55
|
+
%w(count min max outliers_low outliers_high mean std_dev).each do |f|
|
|
56
|
+
$stderr.write "#{f}=#{agg.__send__ f}\n"
|
|
57
|
+
end
|
|
58
|
+
$stderr.write "#{agg}\n\n"
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
trap(:USR1) do
|
|
62
|
+
dump_aggregate "active", agg_active
|
|
63
|
+
dump_aggregate "queued", agg_queued
|
|
64
|
+
end
|
|
65
|
+
trap(:USR2) do
|
|
66
|
+
agg_active = Aggregate.new
|
|
67
|
+
agg_queued = Aggregate.new
|
|
68
|
+
end
|
|
69
|
+
$stderr.puts "USR1(dump_aggregate) and USR2(reset) handlers ready for PID=#$$"
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
ARGV.each do |addr|
|
|
73
|
+
addr =~ %r{\A(127\..+):(\d+)\z} or next
|
|
74
|
+
host, port = $1, $2
|
|
75
|
+
hex_port = '%X' % port.to_i
|
|
76
|
+
ip_addr = IPAddr.new(host)
|
|
77
|
+
hex_host = ip_addr.hton.each_byte.inject('') { |s,o| s << '%02X' % o }
|
|
78
|
+
socks = File.readlines('/proc/net/tcp')
|
|
79
|
+
hex_addr = "#{hex_host}:#{hex_port}"
|
|
80
|
+
if socks.grep(/^\s+\d+:\s+#{hex_addr}\s+/).empty? &&
|
|
81
|
+
! socks.grep(/^\s+\d+:\s+00000000:#{hex_port}\s+/).empty?
|
|
82
|
+
warn "W: #{host}:#{port} (#{hex_addr}) not found in /proc/net/tcp"
|
|
83
|
+
warn "W: Did you mean 0.0.0.0:#{port}?"
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
len = "address".size
|
|
88
|
+
now = nil
|
|
89
|
+
tcp, unix = [], []
|
|
90
|
+
ARGV.each do |addr|
|
|
91
|
+
bs = addr.respond_to?(:bytesize) ? addr.bytesize : addr.size
|
|
92
|
+
len = bs if bs > len
|
|
93
|
+
(addr =~ %r{\A/} ? unix : tcp) << addr
|
|
94
|
+
end
|
|
95
|
+
combined = {}
|
|
96
|
+
tcp_args = unix_args = nil
|
|
97
|
+
unless tcp.empty? && unix.empty?
|
|
98
|
+
tcp_args = tcp
|
|
99
|
+
unix_args = unix
|
|
100
|
+
end
|
|
101
|
+
sock = Raindrops::InetDiagSocket.new if tcp
|
|
102
|
+
|
|
103
|
+
len = 35 if len > 35
|
|
104
|
+
fmt = "%20s % #{len}s % 10u % 10u\n"
|
|
105
|
+
$stderr.printf fmt.tr('u','s'), *%w(timestamp address active queued)
|
|
106
|
+
|
|
107
|
+
begin
|
|
108
|
+
if now
|
|
109
|
+
combined.clear
|
|
110
|
+
now = nil
|
|
111
|
+
end
|
|
112
|
+
combined.merge! Raindrops::Linux.tcp_listener_stats(tcp_args, sock)
|
|
113
|
+
combined.merge! Raindrops::Linux.unix_listener_stats(unix_args)
|
|
114
|
+
combined.each do |addr,stats|
|
|
115
|
+
active, queued = stats.active, stats.queued
|
|
116
|
+
if agg_active
|
|
117
|
+
agg_active << active
|
|
118
|
+
agg_queued << queued
|
|
119
|
+
end
|
|
120
|
+
next if queued < queued_thresh
|
|
121
|
+
printf fmt, now ||= Time.now.utc.iso8601, addr, active, queued
|
|
122
|
+
end
|
|
123
|
+
end while delay && delay_for(delay)
|
data/examples/watcher.ru
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: false
|
|
2
|
+
# This is a snippet of the config that powers
|
|
3
|
+
# https://yhbt.net/raindrops-demo/
|
|
4
|
+
# This may be used with the packaged zbatery.conf.rb
|
|
5
|
+
#
|
|
6
|
+
# zbatery -c zbatery.conf.ru watcher_demo.ru -E none
|
|
7
|
+
require "raindrops"
|
|
8
|
+
use Raindrops::Middleware
|
|
9
|
+
listeners = %w(
|
|
10
|
+
0.0.0.0:9418
|
|
11
|
+
0.0.0.0:80
|
|
12
|
+
/tmp/.r
|
|
13
|
+
)
|
|
14
|
+
run Raindrops::Watcher.new :listeners => listeners
|